Skip to content

Commit

Permalink
Prevents the request from being serialized when debug is not enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
a.stecher committed Aug 26, 2024
1 parent 2028da4 commit 1ae5db0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/caddyhttp/rewrite/rewrite.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ func (rewr *Rewrite) Provision(ctx caddy.Context) error {
func (rewr Rewrite) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error {
repl := r.Context().Value(caddy.ReplacerCtxKey).(*caddy.Replacer)

if rewr.logger.Check(zap.DebugLevel, "rewrote request") == nil {
rewr.Rewrite(r, repl)
return next.ServeHTTP(w, r)
}

logger := rewr.logger.With(
zap.Object("request", caddyhttp.LoggableHTTPRequest{Request: r}),
)
Expand Down

0 comments on commit 1ae5db0

Please sign in to comment.