Skip to content

Commit 6dce493

Browse files
committed
caddyhttp: Alter log message when request is unhandled (close #5182)
1 parent 874d0ce commit 6dce493

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

modules/caddyhttp/caddyhttp.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ type MiddlewareHandler interface {
7676
}
7777

7878
// emptyHandler is used as a no-op handler.
79-
var emptyHandler Handler = HandlerFunc(func(http.ResponseWriter, *http.Request) error { return nil })
79+
var emptyHandler Handler = HandlerFunc(func(_ http.ResponseWriter, req *http.Request) error {
80+
SetVar(req.Context(), "unhandled", true)
81+
return nil
82+
})
8083

8184
// An implicit suffix middleware that, if reached, sets the StatusCode to the
8285
// error stored in the ErrorCtxKey. This is to prevent situations where the
@@ -120,7 +123,7 @@ type ResponseHandler struct {
120123
Routes RouteList `json:"routes,omitempty"`
121124
}
122125

123-
// Provision sets up the routse in rh.
126+
// Provision sets up the routes in rh.
124127
func (rh *ResponseHandler) Provision(ctx caddy.Context) error {
125128
if rh.Routes != nil {
126129
err := rh.Routes.Provision(ctx)

0 commit comments

Comments
 (0)