Update gorilla/mux dependency to v1.8.1

This commit is contained in:
Cameron Moore 2024-03-29 13:05:30 -05:00
parent 81a17df5e0
commit 102e129280
No known key found for this signature in database
GPG key ID: AF96E12468D7553E
17 changed files with 367 additions and 149 deletions

View file

@ -58,22 +58,17 @@ func CORSMethodMiddleware(r *Router) MiddlewareFunc {
func getAllMethodsForRoute(r *Router, req *http.Request) ([]string, error) {
var allMethods []string
err := r.Walk(func(route *Route, _ *Router, _ []*Route) error {
for _, m := range route.matchers {
if _, ok := m.(*routeRegexp); ok {
if m.Match(req, &RouteMatch{}) {
methods, err := route.GetMethods()
if err != nil {
return err
}
allMethods = append(allMethods, methods...)
}
break
for _, route := range r.routes {
var match RouteMatch
if route.Match(req, &match) || match.MatchErr == ErrMethodMismatch {
methods, err := route.GetMethods()
if err != nil {
return nil, err
}
}
return nil
})
return allMethods, err
allMethods = append(allMethods, methods...)
}
}
return allMethods, nil
}