aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/intercept
diff options
context:
space:
mode:
authorKévin Dunglas <[email protected]>2024-09-13 19:16:37 +0200
committerGitHub <[email protected]>2024-09-13 11:16:37 -0600
commitf4bf4e0097853438eb69c573bbaa0581e9b9c02d (patch)
tree2c01222faa34d3c95072094a2f80c41b1563c19e /modules/caddyhttp/intercept
parent21f9c20a04ec5c2ac430daa8e4ba8fbdef67f773 (diff)
downloadcaddy-f4bf4e0097853438eb69c573bbaa0581e9b9c02d.tar.gz
caddy-f4bf4e0097853438eb69c573bbaa0581e9b9c02d.zip
perf: use zap's Check() to prevent useless allocs (#6560)
* perf: use zap's Check() to prevent useless allocs * fix * fix * fix * fix * restore previous replacer behavior * fix linter
Diffstat (limited to 'modules/caddyhttp/intercept')
-rw-r--r--modules/caddyhttp/intercept/intercept.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/modules/caddyhttp/intercept/intercept.go b/modules/caddyhttp/intercept/intercept.go
index 720a09333..29889dcc0 100644
--- a/modules/caddyhttp/intercept/intercept.go
+++ b/modules/caddyhttp/intercept/intercept.go
@@ -23,6 +23,7 @@ import (
"sync"
"go.uber.org/zap"
+ "go.uber.org/zap/zapcore"
"github.com/caddyserver/caddy/v2"
"github.com/caddyserver/caddy/v2/caddyconfig/caddyfile"
@@ -165,7 +166,9 @@ func (ir Intercept) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddy
}
repl.Set("http.intercept.status_code", rec.Status())
- ir.logger.Debug("handling response", zap.Int("handler", rec.handlerIndex))
+ if c := ir.logger.Check(zapcore.DebugLevel, "handling response"); c != nil {
+ c.Write(zap.Int("handler", rec.handlerIndex))
+ }
// pass the request through the response handler routes
return rec.handler.Routes.Compile(next).ServeHTTP(w, r)