Group routes does not work without leading slash
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 32.7k
- Forks
- 2.7k
- Avg merge
- 9h 35m
- Merged PRs (30d)
- 6
Description
Group route does not work without leading slash
I ran into an unexpected behavior with grouped routes.
g := e.Group("/v1")
g.GET("posts", handler)
Requesting:
GET /v1/posts
returns:
Not Found
Changing it to:
g.GET("/posts", handler)
works as expected.
I would expect Echo to handle the missing leading / when combining the group prefix and route path, or at least provide a warning during route registration.
It would be nice if both forms resulted in /v1/posts:
g.GET("posts", handler)
g.GET("/posts", handler)
Because it is very normal for a developer to not provide the slash since a group already means it's under that group (so slash should come automatically)
Otherwise its too confusing and something to forget easily when using the framework!!
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.
Research direction
Start by reproducing the grouped-route example in the issue and trace Echo's group route registration and matching behavior. Add regression coverage for both g.GET("posts", handler) and g.GET("/posts", handler) under /v1; done means requests to /v1/posts resolve in both cases, or the documented warning behavior is covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 74/100