Unclear behaviour of `*` in routes
Open
@aldas is already working on this.
Since Apr 6, 2024.
feature
router
- Dominant language
- Go
- Stars
- 32.7k
- Forks
- 2.7k
- Avg merge
- 9h 35m
- Merged PRs (30d)
- 6
Description
Issue Description
Checklist
- Dependencies installed
- No typos
- Searched existing issues and docs
Expected behaviour
- If I have static text in a route that static text is guaranteed to show up in
c.Path()orc.Request().RequestURI - Multiple instances of
*in routes play nicely with each other
Actual behaviour
- If I have static text in a route, another route with
*may "absorb it" - Multiple instances of
*in routes do NOT seem to play nicely with each other
Steps to reproduce
Trying to build router for: https://github.com/opencontainers/distribution-spec/blob/main/spec.md
handler := func (c echo.Context) err {
fmt.Printf("%s\n", c.Path())
}
e := echo.New()
v2 := e.Group("/v2")
v2.DELETE("/*/blobs/:digest", handler)
v2.GET("/*/blobs/:digest", handler)
v2.HEAD("/*/blobs/:digest", handler)
v2.DELETE("/*/manifests/:ref", handler)
v2.GET("/*/manifests/:ref", handler)
v2.HEAD("/*/manifests/:ref", handler)
v2.PUT("/*/manifests/:ref", handler)
v2.GET("/*/tags/list", handler)
v2.GET("/*/blobs/uploads/:ref", handler)
v2.PATCH("/*/blobs/uploads/:ref", handler)
v2.POST("/*/blobs/uploads", handler)
v2.PUT("/*/blobs/uploads/:ref", handler)
v2.GET("", handler)
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.