-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subrouters match the wrong method when more than one matches #300
Comments
I'm facing the same problem as you @silverweed, but with another route setup. (Would you think these might be related? If not, I will open a new issue.) With the following code: `
} func getFunc(w http.ResponseWriter, r *http.Request) {
} func postFunc(w http.ResponseWriter, r *http.Request) {
} A GET to localhost:3000/test will result in: A GET to localhost:3000/test/ will result in: A POST to localhost:3000/test will result in: A POST to localhost:3000/test/ will result in: |
This has hit us too, the current 1.5.0 release is totally broken for any users that have Method based routing. This means anyone updating using ^1.x... semantic versioning will end up with broken apps. Given this there really needs to be 1.5.1 release urgently to address this. |
Pinging @kisielk, because I’m away, but if it’s critical I suggest updating
your dependency manifest to pin against the ref that resolves the bug
(which is what makes pinning useful!).
…On Thu, Oct 19, 2017 at 1:11 PM Steven Hartland ***@***.***> wrote:
This has hit us too, the current 1.5.0 release is totally broken for any
users that have Method based routing.
It appears to be fixed in master, but no release has been performed yet
which means anyone updating using ^1.x... semantic versioning will end up
with broken apps.
Given this there really need to be 1.5.1 release urgently to address this.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#300 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AABIcC2JR7kIHRG4XhRWGPLxfvtYxgfvks5sty5zgaJpZM4PqdDa>
.
|
Yes thats exactly what we’ve done but not before it caused an outage for our customers. |
Maybe I can look into this if any of the affected users add some test cases. I just tweaked this code in #311, so it shouldn't be difficult for me to fix this. |
Plan:
1. Add more test cases to the library for this - especially around
Subrouters / PathPrefix cases, to see whether we can reproduce internally
w/o user code
2. If identifies issues, fix.
There are already a good number of tests for no. 1 so these reports are
worrying, but definitely want to fix. I'll earmark some time tomorrow to
tackle no. 1.
…On Fri, Nov 3, 2017 at 11:23 AM Roberto Santalla ***@***.***> wrote:
Maybe I can look into this if any of the affected users add some test
cases. I just tweaked this code in #311
<#311>, so it shouldn't be difficult
for me to fix this.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#300 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AABIcN-TO4CmdI-Wj4fjkitvpRhKWsI4ks5sy1ovgaJpZM4PqdDa>
.
|
Maybe I can take a look at the user examples to see if they can be ported to tests. I'll give it a try tomorrow. |
Hi @roobre, are you still working on this? If not, I'd like to take a stab at it. I found something odd here: https://github.com/gorilla/mux/blob/master/route.go#L84 |
I'm quite on hold since reviewers are on vacation :( I planned to get on this when my PR (#294) gets resolved, but if you want to look at it, be my guest :3 |
* Test method-based subrouters for multiple matching paths * Pass TestMethodsSubrouter * Change http.Method* constants to string literals - Make compatible with Go v1.5 * Make TestMethodsSubrouter stateless and concurrent * Remove t.Run and break up tests for concurrency * Use backticks to remove quote escaping * Remove global method handlers and HTTP method constants
@silverweed @leofachini @stevenh @roobre can you check if the PR today fixed this for you? |
@kisielk Looks like it's working well :) |
Closing this out. |
I remove the strictSlash and everything work |
Introduced by #288.
Given the following code:
a POST request to /some/thing will always match the
get
subrouter:curl localhost:8888/some/thing -X POST # -> get
The same happens when there is a subrouter with a "catch-all" route, like
This route will match any valid POST route without parameters.
These behaviours happen no matter the calling order of the
HandleFunc
s.Commenting these lines seems to solve the issue, but of course breaks #288
The text was updated successfully, but these errors were encountered: