Skip to content

Commit

Permalink
fix: route builder sorts the middlewares before using them
Browse files Browse the repository at this point in the history
  • Loading branch information
xgfone committed Oct 25, 2024
1 parent f4db60b commit 0d2cc5d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion http/router/ruler/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,13 @@ func (b RouteBuilder) newRoute(handler http.Handler) (route Route) {
route = b.route
route.Matcher = matcher
route.Handler = handler
route.Use(b.mdws)

mdws := make(middleware.Middlewares, 0, len(b.mdws)+1)
mdws = append(mdws, b.mdws...)
if len(mdws) > 0 {
mdws.Sort()
route.Use(mdws...)
}

if route.Priority == 0 {
route.Priority = matcher.Priority()
Expand Down

0 comments on commit 0d2cc5d

Please sign in to comment.