From 6dce4934f0ba3bbf4e69273faf6d00db8f4c2852 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Fri, 10 May 2024 15:49:34 -0600 Subject: [PATCH] caddyhttp: Alter log message when request is unhandled (close #5182) --- modules/caddyhttp/caddyhttp.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/caddyhttp/caddyhttp.go b/modules/caddyhttp/caddyhttp.go index 26b21b54..f42b166c 100644 --- a/modules/caddyhttp/caddyhttp.go +++ b/modules/caddyhttp/caddyhttp.go @@ -76,7 +76,10 @@ type MiddlewareHandler interface { } // emptyHandler is used as a no-op handler. -var emptyHandler Handler = HandlerFunc(func(http.ResponseWriter, *http.Request) error { return nil }) +var emptyHandler Handler = HandlerFunc(func(_ http.ResponseWriter, req *http.Request) error { + SetVar(req.Context(), "unhandled", true) + return nil +}) // An implicit suffix middleware that, if reached, sets the StatusCode to the // error stored in the ErrorCtxKey. This is to prevent situations where the @@ -120,7 +123,7 @@ type ResponseHandler struct { Routes RouteList `json:"routes,omitempty"` } -// Provision sets up the routse in rh. +// Provision sets up the routes in rh. func (rh *ResponseHandler) Provision(ctx caddy.Context) error { if rh.Routes != nil { err := rh.Routes.Provision(ctx)