Fix middlewares getting overwritten
This commit is contained in:
parent
317961ab6e
commit
2a612eb82f
@ -136,7 +136,11 @@ func (r *Router) getHttpr() *httprouter.Router {
|
|||||||
handle = handlePOST(r, v.Handle)
|
handle = handlePOST(r, v.Handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
httpr.Handle(v.Method, v.Path, handleReq(r, handle, append(r.middleware, v.Middleware...)))
|
middleware := make([]Middleware, len(r.middleware)+len(v.Middleware))
|
||||||
|
copy(middleware, r.middleware)
|
||||||
|
copy(middleware[len(r.middleware):], v.Middleware)
|
||||||
|
|
||||||
|
httpr.Handle(v.Method, v.Path, handleReq(r, handle, middleware))
|
||||||
}
|
}
|
||||||
|
|
||||||
httpr.NotFound = http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
httpr.NotFound = http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||||
|
Loading…
Reference in New Issue
Block a user