summaryrefslogtreecommitdiffstats
path: root/modules/web
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-04-06 16:40:56 +0100
committerGitHub <noreply@github.com>2021-04-06 17:40:56 +0200
commitb101fa83a6d75922d079e2b7e0437a123a90bb62 (patch)
treea071d2c8afb261ca7a28164a330263972f0aec62 /modules/web
parent5f18404045f1979fab34583277ad2a1bfab81ed9 (diff)
downloadgitea-b101fa83a6d75922d079e2b7e0437a123a90bb62.tar.gz
gitea-b101fa83a6d75922d079e2b7e0437a123a90bb62.zip
Fix bug in Wrap (#15302)
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 <art27@cantab.net>
Diffstat (limited to 'modules/web')
-rw-r--r--modules/web/route.go7
1 files 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))
}