Skip to content

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

Closed
wyf027 wants to merge 1 commit into
gorilla:mainfrom
wyf027:fix/route-methods-merge-694
Closed

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

Conversation

@wyf027

@wyf027 wyf027 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 #694
@wyf027
wyf027 force-pushed the fix/route-methods-merge-694 branch from 69b535b to 50a3f77 Compare May 26, 2026 04:37
@wyf027 wyf027 closed this by deleting the head repository Jun 23, 2026
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