fix: only add log middleware to not found handler when enabled (#3969)

This commit is contained in:
Alex Last 2024-03-05 04:14:54 +00:00 committed by GitHub
parent 2096cd5749
commit ba1d6e3664
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -217,9 +217,12 @@ func (ng *engine) notFoundHandler(next http.Handler) http.Handler {
handler.TraceHandler(ng.conf.Name,
"",
handler.WithTraceIgnorePaths(ng.conf.TraceIgnorePaths)),
ng.getLogHandler(),
)
if ng.conf.Middlewares.Log {
chn = chn.Append(ng.getLogHandler())
}
var h http.Handler
if next != nil {
h = chn.Then(next)