Skip to content

fix: merge methods when Route.Methods is called repeatedly#802

Open
leno23 wants to merge 1 commit into
gorilla:mainfrom
leno23:fix/route-methods-merge-694
Open

fix: merge methods when Route.Methods is called repeatedly#802
leno23 wants to merge 1 commit into
gorilla:mainfrom
leno23:fix/route-methods-merge-694

Conversation

@leno23

@leno23 leno23 commented May 25, 2026

Copy link
Copy Markdown

Summary

Calling Route.Methods() more than once on the same route previously added independent method matchers. A request had to satisfy every matcher, which is impossible for a single HTTP method and surfaced as 405 Method Not Allowed (e.g. .Methods("PUT").Methods("PATCH")).

Repeated calls now merge into one matcher. GetMethods() aggregates methods from all method matchers on the route.

Fixes #694

Test plan

  • go test ./...
  • Added TestRouteMethodsRepeatedCalls
  • Updated TestSubrouterMatching/method expectations for merged semantics

Chaining Methods() on the same route previously added independent
matchers, requiring every method to match the same request and causing
405 responses for valid verbs like PUT and PATCH.

Merge repeated calls into a single method matcher and aggregate methods
in GetMethods().

Fixes gorilla#694
@leno23 leno23 force-pushed the fix/route-methods-merge-694 branch from 69b535b to 50a3f77 Compare May 26, 2026 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Using route.Methods(...) more than once

1 participant