File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -50,12 +50,15 @@ func (r *Route) Match(req *http.Request, match *RouteMatch) bool {
50
50
}
51
51
52
52
var matchErr error
53
+ methodMismatch := false // Track method mismatch
53
54
54
55
// Match everything.
55
56
for _ , m := range r .matchers {
56
57
if matched := m .Match (req , match ); ! matched {
58
+ // Detect mismatch due to HTTP method
57
59
if _ , ok := m .(methodMatcher ); ok {
58
60
matchErr = ErrMethodMismatch
61
+ methodMismatch = true // Flag method mismatch
59
62
continue
60
63
}
61
64
@@ -88,6 +91,13 @@ func (r *Route) Match(req *http.Request, match *RouteMatch) bool {
88
91
}
89
92
}
90
93
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
91
101
if matchErr != nil {
92
102
match .MatchErr = matchErr
93
103
return false
You can’t perform that action at this time.
0 commit comments