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
Seeing "panic: wildcard route conflicts with existing children" unexpectedly #12
Comments
Intended. The intention is, that there is only one or none possible route for any prefix when matching incoming requests. But if someone requests |
I have the same issue. Take the following example: a.mux.POST("users/:id/verify", user.Verify)
a.mux.POST("users/activated", user.GetActivatedUsers) The first verifies one special user while the second returns a collection of activated users based on the request payload. This is possible with many modern routers so the decision really surprised me. |
I have the same problem as @CodingRogue. Surprisingly, we're both doing something user-related.. users.GET("/new")
users.GET("/:id/edit") Something like |
I'm afraid this will happen quite often in more complex rest apis. Is there any solution or workaround except switching routers? |
You could probably embed httprouter in a new struct and refine httprouter's methods to support the routes above. But I ended up just replacing httprouter with gorilla/pat. gorilla/pat also has regex matching so you can match numbers. |
I will check out pat then, thanks. |
the routes
For fix your routes, should look like: a.mux.POST("user/:id", user.Profile)
a.mux.POST("user/:id/verify", user.Verify)
a.mux.POST("users", user.GetAll)
a.mux.POST("users/activated", user.GetActivatedUsers) |
I can see your point but this route design is not REST compatible. I need to have the same resource identifier reachable through all necessary http verbs (GET, POST, PUT, PATCH, DELETE...). |
But each http verb must do things differently from the rest... |
I hit the same issue. I think this is a pretty common use case, and something I would love to see gin accommodate. You can see similar patterns in GitHub, Twitter, Facebook, etc:
|
When trying to add simple routes that should not overlap, I get wildcard route conflicts.
Simple crafted example:
In the sample code the routes that appear to conflict are
/:some/:thing
and/otherthing
. These should not really be conflicting though, as one requires two path components, and the other is a fixed route with no wildcards. Kind of odd. Is this a bug or intended behavior?The text was updated successfully, but these errors were encountered: