Skip to content

Commit

Permalink
fix(router): fixes middleware order
Browse files Browse the repository at this point in the history
  • Loading branch information
ConsoleTVs committed Nov 26, 2024
1 parent ccc1c72 commit 2c5b06a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions problem.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ type Problem struct {
Instance string
}

// ProblemControlsResolver is a func that resolves to a response T given
// a [Problem] and a [http.Request].
type ProblemControlsResolver[R any] func(problem Problem, request *http.Request) R

type ProblemControls struct {
Expand Down
4 changes: 2 additions & 2 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ func (router *Router) mux() *http.ServeMux {
// the same as first calling the router middlewares and then the
// provided [http.Handler].
func (router *Router) wrap(handler http.Handler) http.Handler {
for _, middleware := range router.middlewares {
handler = middleware(handler)
for i := len(router.middlewares) - 1; i >= 0; i-- {
handler = router.middlewares[i](handler)
}

return handler
Expand Down

0 comments on commit 2c5b06a

Please sign in to comment.