MCPcopy
hub / github.com/labstack/echo / BenchmarkRequestLogger_withMapFields

Function BenchmarkRequestLogger_withMapFields

middleware/request_logger_test.go:584–631  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

582}
583
584func BenchmarkRequestLogger_withMapFields(b *testing.B) {
585 e := echo.New()
586
587 mw := RequestLoggerWithConfig(RequestLoggerConfig{
588 LogValuesFunc: func(c *echo.Context, values RequestLoggerValues) error {
589 return nil
590 },
591 LogLatency: true,
592 LogProtocol: true,
593 LogRemoteIP: true,
594 LogHost: true,
595 LogMethod: true,
596 LogURI: true,
597 LogURIPath: true,
598 LogRoutePath: true,
599 LogRequestID: true,
600 LogReferer: true,
601 LogUserAgent: true,
602 LogStatus: true,
603 LogContentLength: true,
604 LogResponseSize: true,
605 LogHeaders: []string{"accept-encoding", "User-Agent"},
606 LogQueryParams: []string{"lang", "checked"},
607 LogFormValues: []string{"csrf", "multiple"},
608 })(func(c *echo.Context) error {
609 c.Request().Header.Set(echo.HeaderXRequestID, "123")
610 c.FormValue("to force parse form")
611 return c.String(http.StatusTeapot, "OK")
612 })
613
614 f := make(url.Values)
615 f.Set("csrf", "token")
616 f.Add("multiple", "1")
617 f.Add("multiple", "2")
618 req := httptest.NewRequest(http.MethodPost, "/test?lang=en&checked=1&checked=2", strings.NewReader(f.Encode()))
619 req.Header.Set("Referer", "https://echo.labstack.com/")
620 req.Header.Set("User-Agent", "curl/7.68.0")
621 req.Header.Add(echo.HeaderContentType, echo.MIMEApplicationForm)
622
623 b.ReportAllocs()
624 b.ResetTimer()
625
626 for i := 0; i < b.N; i++ {
627 rec := httptest.NewRecorder()
628 c := e.NewContext(req, rec)
629 mw(c)
630 }
631}

Callers

nothing calls this directly

Calls 7

RequestMethod · 0.95
FormValueMethod · 0.95
StringMethod · 0.95
RequestLoggerWithConfigFunction · 0.85
SetMethod · 0.80
NewContextMethod · 0.80
AddMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…