Skip to content

Commit

Permalink
small optimization for wrap method
Browse files Browse the repository at this point in the history
simplify the logic and make it a bit more performant
  • Loading branch information
umputun committed Jan 3, 2025
1 parent ae8e1e5 commit 7a0b651
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions group.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ func (b *Bundle) Route(configureFn func(*Bundle)) { configureFn(b) }

// wrapMiddleware applies the registered middlewares to a handler.
func (b *Bundle) wrapMiddleware(handler http.Handler) http.Handler {
for i := range b.middlewares {
handler = b.middlewares[len(b.middlewares)-1-i](handler)
for i := len(b.middlewares) - 1; i >= 0; i-- {
handler = b.middlewares[i](handler)
}
return handler
}
Expand Down

0 comments on commit 7a0b651

Please sign in to comment.