Skip to content

segment conflicts with existing wildcard #1301

@68696c6c

Description

@68696c6c

I found a few other issues that look like they are related to this problem, but they are all closed and I'm not sure what the status of this bug is, so I'm making a new issue here...

As an example I've defined two routes, one to get a user by their ID, and another to get a user by their email:

	apiRoutes := r.Engine.Group("/api")
	apiRoutes.GET("/users/:id", GetUser)
	apiRoutes.GET("/users/email/:email", GetUser)

When I try and build, I get this error:

panic: path segment 'email/:email' conflicts with existing wildcard ':id' in path '/api/users/email/:email'

The problem is that these routes are NOT ambiguous and shouldn't conflict. I'm using Gin in several APIs and run into this problem in all of them in various ways. The above code is just a simplified demonstration of the bug.

Based on the closed issues I've found here:
#205
#388

That last issue referenced this open issue in httprouter:
julienschmidt/httprouter#73

...but that issue hasn't been updated since 2015...

So it seems the Gin team is aware of this bug, but it isn't clear whether or not it's going to be fixed. I'm just posting this to get some clarity on the problem.

Thanks!

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