Skip to content

Unclear behaviour of * in routes #2619

Open
@izaakschroeder

Description

@izaakschroeder

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() or c.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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions