Skip to content

Commit b101fa8

Browse files
authored
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 <[email protected]>
1 parent 5f18404 commit b101fa8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

modules/web/route.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ func Wrap(handlers ...interface{}) http.HandlerFunc {
6868
}
6969
case func(http.Handler) http.Handler:
7070
var next = http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})
71-
t(next).ServeHTTP(resp, req)
72-
if r, ok := resp.(context.ResponseWriter); ok && r.Status() > 0 {
73-
return
71+
if len(handlers) > i+1 {
72+
next = Wrap(handlers[i+1:]...)
7473
}
74+
t(next).ServeHTTP(resp, req)
75+
return
7576
default:
7677
panic(fmt.Sprintf("Unsupported handler type: %#v", t))
7778
}

0 commit comments

Comments
 (0)