labstack / labstack/echo

Group routes does not work without leading slash

Open Beginner friendly
#3,099 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.