-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
segment conflicts with existing wildcard #1301
Comments
Hi @68696c6c - it's not really a bug, but a known limitation. The downside of not using regular expressions for route matching is that paths have to be unique. Unfortunately afaik this behavior is not going to change any time soon. |
Understood, thank you. However, I was fiddling with this more today and found a workaround that I wanted to share here in case anyone else comes across this issue. If I change my routes to look like this, everything works fine:
Basically, both routes need to have the wildcard in the same position, and the wildcards need to be named the same thing. |
Do you have some good alternatives? I encounter the same problem... |
why not change name? like:
|
I needed such routes:
I have to switch to the next model:
|
Router:
bad Function
|
Any solution yet? |
Why this closed? GIN route matching is super ugly. |
We generated a Presigned Url for PUT and GET PUT Presigned url will be used to make a put request to upload an image to our S3 bucket GET presinged url will be used to load an image Both links expires after 5 mins FYI: I did some code refactoring in for our multiplexer. Route matching with the julienschmidt multiplexer was so bad! gin-gonic/gin#1301
There was a PR to improve httprouter used by gin: julienschmidt/httprouter#329. |
Guys? |
I found a few other issues that look like they are related to this problem, but they are all closed and I'm not sure what the status of this bug is, so I'm making a new issue here...
As an example I've defined two routes, one to get a user by their ID, and another to get a user by their email:
When I try and build, I get this error:
The problem is that these routes are NOT ambiguous and shouldn't conflict. I'm using Gin in several APIs and run into this problem in all of them in various ways. The above code is just a simplified demonstration of the bug.
Based on the closed issues I've found here:
#205
#388
That last issue referenced this open issue in httprouter:
julienschmidt/httprouter#73
...but that issue hasn't been updated since 2015...
So it seems the Gin team is aware of this bug, but it isn't clear whether or not it's going to be fixed. I'm just posting this to get some clarity on the problem.
Thanks!
The text was updated successfully, but these errors were encountered: