-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Route conflict #875
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
Comments
httprouter has this problem which is a radix tree based router also. |
Echo already does better than httprouter in this regard. From httprouter README:
Echo uses the same patterns as a working example on the Routing page of the guide: e.GET("/users/:id", func(c echo.Context) error {
return c.String(http.StatusOK, "/users/:id")
})
e.GET("/users/new", func(c echo.Context) error {
return c.String(http.StatusOK, "/users/new")
})
e.GET("/users/1/files/*", func(c echo.Context) error {
return c.String(http.StatusOK, "/users/1/files/*")
}) |
The reason for this is the way the radix tree is created.
your 3rd test hits on I'm not sure if this is a limitation of the radix tree, or something specific to echo, but I figured I'd at least comment for those that see this in the future. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Description
If I have two routes defined, one with a static value and one with a path param, the static value cannot be used as the path param even if the two routes do not have the same number of path segments.
For example, if I define these two routes:
The second route fails when
:resourceId
isusers
(but works for any other value). I'm confused by this behavior. I know the matching order is static -> param -> any, but I would have thought that if no match was found down the static/users
path, the router would then attempt to match down the/:resourceId
path.Checklist
Expected behaviour
All of these requests should work:
Actual behaviour
These two work:
But this fails:
Steps to reproduce
Working code to debug
Version/commit
3.1.0-rc1
The text was updated successfully, but these errors were encountered: