-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Unclear behaviour of *
in routes
#2619
Comments
Current Router behavior/limitation with TLDR: router does not have functionality to handle |
Thanks for the fast reply @aldas 😄 Is there any plan to change this? I saw in the router test file there is something that looks a little similar: https://github.com/labstack/echo/blob/master/router_test.go#L924 |
This has been raised before. It seems that routes like that are popular lately. I would like Router to have that feature but I am not sure this will happen any time soon. At least 1 month time frame. If you would like to delve into Router internals and maybe submit PR for it. I would gladly review it. ps. I'll investigate this feature this weekend. maybe it is not that complex that fear it to be. |
Linking recent similar issue #2617 p.s. I proposed workaround in that case. It is not pretty but works for suffix matches. This is side note for myself or any person reading this in the future. Problem with matching parts of request URL to route params (including wildcard Defining rules for suffixes For example: e.GET("/*/list", handler)
e.GET("/*/images", handler) and request URL now consider this case: e.GET("/*/list*", handler) // 1
e.GET("/*/images*", handler) // 2 and request URL I looked into different router implementation in Go ecosystem and there are different approaches. I personally do not think that the order in routes added should change how router matches but this would cost less CPU cycles and deciding which routes matches with shortest match means that we need to check more cases. |
I'll update echo documentation with remark that |
note to self: It would be worthwhile to investigate how Nginx/Apache do path matching. These should have solved same issues 15-20 years ago already. And we are about to reinvent the wheel here. some other links: |
Thanks for looking into this a bit more @aldas 😄 I will keep my eyes out for any developments! I'm not sure if I have the brains enough myself to go spelunking through the routing code to fix this one myself 😓 |
#2657 |
Issue Description
Checklist
Expected behaviour
c.Path()
orc.Request().RequestURI
*
in routes play nicely with each otherActual behaviour
*
may "absorb it"*
in routes do NOT seem to play nicely with each otherSteps to reproduce
Trying to build router for: https://github.com/opencontainers/distribution-spec/blob/main/spec.md
Run:
curl -ik https://localhost:8080/v2/foo/bar/baz/tags/list # /v2/*/blobs/uploads/:ref
Result outputs
/v2/*/blobs/uploads/:ref
when it should output/v2/*/tags/list
.Version/commit
v4.11.4
The text was updated successfully, but these errors were encountered: