Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wildcard conflicts #1756

Closed
CaiJinKen opened this issue Jan 30, 2019 · 1 comment · Fixed by #2663
Closed

wildcard conflicts #1756

CaiJinKen opened this issue Jan 30, 2019 · 1 comment · Fixed by #2663

Comments

@CaiJinKen
Copy link

  • With issues:

    • Use the search tool before opening a new issue.
    • Please provide source code and commit sha if you found a bug.
    • Review existing issues and provide feedback or react to them.
  • go version: go1.11.1

  • gin version (or commit ref): v1.3.0

  • operating system: x86_64 GNU/Linux 4.8.0-36-generic

Description

I user router llike this:

session := v2.Group("/sessions")
{
	session.POST("", controllers.Login)
	session.DELETE("/:user_id", controllers.Logout)
	session.POST("/signup", controllers.SignUp)
	session.POST("/forgot_password", controllers.PassBack)
	session.POST("/:user_id/scan", controllers.ScanLogin)
}

but error returns on logs, the methods of sessions/:user_id & sessions/:user_id/scan are deferrent actrauly.

[GIN-debug] POST   /api/v2/sessions          --> app/cmd/http/controllers.Login (4 handlers)
[GIN-debug] DELETE /api/v2/sessions/:user_id --> app/cmd/http/controllers.Logout (4 handlers)
[GIN-debug] POST   /api/v2/sessions/signup   --> app/cmd/http/controllers.SignUp (4 handlers)
[GIN-debug] POST   /api/v2/sessions/forgot_password --> 
![selection_050](https://user-images.githubusercontent.com/36183188/51963956-0c39e980-24a0-11e9-8761-a1a160d53b7a.png)
app/cmd/http/controllers.PassBack (4 handlers)
[GIN-debug] POST   /api/v2/sessions/:user_id/scan --> app/cmd/http/controllers.ScanLogin (4 handlers)
panic: wildcard route ':user_id' conflicts with existing children in path '/api/v2/sessions/:user_id/scan'

How can i fix this?? Thank you very much.

Screenshots

@thinkerou
Copy link
Member

thinkerou commented Jan 30, 2019

Likes:

session := v2.Group("/sessions")
{
	session.POST("", controllers.Login)
	session.DELETE("/logout/:user_id", controllers.Logout)
	session.POST("/signup", controllers.SignUp)
	session.POST("/forgot_password", controllers.PassBack)
	session.POST("/scan/:user_id", controllers.ScanLogin)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants