Fix SupressNotFound making subrouters return 404 and add tests for SupressNotFound#940
Open
ezraisw wants to merge 6 commits into
Open
Fix SupressNotFound making subrouters return 404 and add tests for SupressNotFound#940ezraisw wants to merge 6 commits into
SupressNotFound making subrouters return 404 and add tests for SupressNotFound#940ezraisw wants to merge 6 commits into
Conversation
SupressNotFound making subrouters 404SupressNotFound making subrouters return 404 and add tests for SupressNotFound
|
wow, I was wondering why. Looks great! |
|
I'm having the same problem, @pkieltyka could you take a look at this? |
|
@VojtechVitek could you take a look at this? It has been around for a long time. |
|
@VojtechVitek why hasn't this PR been merged yet? |
|
This is a pretty glaring bug. I unfortunately spent a couple of hours before realizing this issue |
Author
|
FYI, this middleware returns 404 instead of 405 for requests with valid paths that have incorrect HTTP methods. Supporting 405 response would require a bigger change within the |
VojtechVitek
approved these changes
Jul 28, 2025
VojtechVitek
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Thank you!
Can someone please help me test this PR and verify its behavior? 👀
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes #939 by using
NewRouteContext()to create a new route context before calling theMatchfunction.Because of
Match's behavior of modifying route context, it is necessary to for the route context to be isolated.chi/mux.go
Lines 361 to 362 in 23c395f
Also added tests to enforce this logic.