Skip to content

Commit

Permalink
fix go-chi#587 by reverting 894714a and 00cc734 (go-chi#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkieltyka authored Mar 25, 2021
1 parent ab14a9a commit 969d7fc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,17 @@ func (mx *Mux) Trace(pattern string, handlerFn http.HandlerFunc) {
func (mx *Mux) NotFound(handlerFn http.HandlerFunc) {
// Build NotFound handler chain
m := mx
h := Chain(mx.middlewares...).HandlerFunc(handlerFn).ServeHTTP
hFn := handlerFn
if mx.inline && mx.parent != nil {
m = mx.parent
hFn = Chain(mx.middlewares...).HandlerFunc(hFn).ServeHTTP
}

// Update the notFoundHandler from this point forward
m.notFoundHandler = h
m.notFoundHandler = hFn
m.updateSubRoutes(func(subMux *Mux) {
if subMux.notFoundHandler == nil {
subMux.NotFound(h)
subMux.NotFound(hFn)
}
})
}
Expand All @@ -208,16 +209,17 @@ func (mx *Mux) NotFound(handlerFn http.HandlerFunc) {
func (mx *Mux) MethodNotAllowed(handlerFn http.HandlerFunc) {
// Build MethodNotAllowed handler chain
m := mx
h := Chain(mx.middlewares...).HandlerFunc(handlerFn).ServeHTTP
hFn := handlerFn
if mx.inline && mx.parent != nil {
m = mx.parent
hFn = Chain(mx.middlewares...).HandlerFunc(hFn).ServeHTTP
}

// Update the methodNotAllowedHandler from this point forward
m.methodNotAllowedHandler = h
m.methodNotAllowedHandler = hFn
m.updateSubRoutes(func(subMux *Mux) {
if subMux.methodNotAllowedHandler == nil {
subMux.MethodNotAllowed(h)
subMux.MethodNotAllowed(hFn)
}
})
}
Expand Down

0 comments on commit 969d7fc

Please sign in to comment.