Skip to content

Commit 88697e9

Browse files
committed
1 parent db9d1d0 commit 88697e9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

route.go

+10
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@ func (r *Route) Match(req *http.Request, match *RouteMatch) bool {
5050
}
5151

5252
var matchErr error
53+
methodMismatch := false // Track method mismatch
5354

5455
// Match everything.
5556
for _, m := range r.matchers {
5657
if matched := m.Match(req, match); !matched {
58+
// Detect mismatch due to HTTP method
5759
if _, ok := m.(methodMatcher); ok {
5860
matchErr = ErrMethodMismatch
61+
methodMismatch = true // Flag method mismatch
5962
continue
6063
}
6164

@@ -88,6 +91,13 @@ func (r *Route) Match(req *http.Request, match *RouteMatch) bool {
8891
}
8992
}
9093

94+
// If flagged method mismatch, return 405
95+
if methodMismatch {
96+
match.MatchErr = ErrMethodMismatch
97+
return false
98+
}
99+
100+
// No match errors, but handle method matches
91101
if matchErr != nil {
92102
match.MatchErr = matchErr
93103
return false

0 commit comments

Comments
 (0)