Skip to content

Commit

Permalink
fix: ordering in which middleware is registered for a route
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanhitt committed Mar 25, 2024
1 parent 81d7826 commit 55c025c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mux.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ func RegisterStd(s *Server, method string, path string, controller func(http.Res
}

func withMiddlewares(controller http.Handler, middlewares ...func(http.Handler) http.Handler) http.Handler {
for _, middleware := range middlewares {
controller = middleware(controller)
for i := len(middlewares) - 1; i >= 0; i-- {
controller = middlewares[i](controller)
}
return controller
}
Expand Down

0 comments on commit 55c025c

Please sign in to comment.