Skip to content

Group routes does not work without leading slash #3099

Description

@sayeed1999

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!!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions