Add unknown location logging with path prefix suppression

This commit is contained in:
gr-dv committed 2026-11-25 17:49:38 +03:00
1 parent 8012ad57fe
commit 48af0bb132
9 files changed
+379 -11

No files matched your search

+7
View File
@@ -96,6 +96,8 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
skipBodyLoggingEndpointPrefixes = append(skipBodyLoggingEndpointPrefixes, strings.TrimPrefix(prefix, "/"))
}
skipLogging := middleware.NewSkipLoggingPaths(config.Logging.SkipLoggingPathPrefixes)
mux := mux2.NewRouter()
for _, location := range locations {
var proxyFunc middleware.Handler
@@ -136,6 +138,7 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
middleware.Logger(
l.logger, config.Logging.RequestLogEnable,
enableBodyLog,
skipLogging,
skipBodyLoggingEndpointPrefixes,
config.Logging.EnableForceUnescapingUnicode,
),
@@ -160,6 +163,7 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
proxyFunc,
middleware.Logger(l.logger, config.Logging.RequestLogEnable,
enableBodyLog,
skipLogging,
skipBodyLoggingEndpointPrefixes,
config.Logging.EnableForceUnescapingUnicode,
),
@@ -177,6 +181,7 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
PathPrefix: location.PathPrefix,
ErrorOnUnknownEndpoint: errorOnUnknownEndpoint,
WithLendingSlash: location.Protocol != conf.GrpcProtocol,
SkipLogging: skipLogging,
},
l.routes,
l.logger,
@@ -184,5 +189,7 @@ func (l Locator) Handler(config conf.Remote, locations []conf.Location) (http.Ha
mux.PathPrefix(location.PathPrefix).Handler(entrypoint)
}
mux.NotFoundHandler = middleware.UnknownLocation(l.logger, skipLogging)
return mux, nil
}