From a8c6a4a70e4f7cf1ae5022d86fda020a930cf7a7 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 6 Apr 2021 18:44:24 +0200 Subject: [PATCH] Fix bug in Wrap (#15302) (#15309) Whilst doing other work I have noticed that there is an issue with Wrap when passing an http.Handler - the next should be the next handler in line not empty. Signed-off-by: Andrew Thornton Co-authored-by: zeripath --- modules/web/route.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/web/route.go b/modules/web/route.go index 59e22c5be1..6f9e76bdf3 100644 --- a/modules/web/route.go +++ b/modules/web/route.go @@ -68,10 +68,11 @@ func Wrap(handlers ...interface{}) http.HandlerFunc { } case func(http.Handler) http.Handler: var next = http.HandlerFunc(func(http.ResponseWriter, *http.Request) {}) - t(next).ServeHTTP(resp, req) - if r, ok := resp.(context.ResponseWriter); ok && r.Status() > 0 { - return + if len(handlers) > i+1 { + next = Wrap(handlers[i+1:]...) } + t(next).ServeHTTP(resp, req) + return default: panic(fmt.Sprintf("Unsupported handler type: %#v", t)) }