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 route conflicts with existing children" #1681

Closed
wodim opened this issue Dec 4, 2018 · 14 comments · Fixed by #2663
Closed

"wildcard route conflicts with existing children" #1681

wodim opened this issue Dec 4, 2018 · 14 comments · Fixed by #2663

Comments

@wodim
Copy link

wodim commented Dec 4, 2018

router.GET("/:something/", Blabla)
router.GET("/:something/else", Bleble)
router.GET("/:something/:different/:again", Blibli)

panic: wildcard route ':different' conflicts with existing children in path '/:something/:different/:again'

Am I doing something wrong or is this simply not allowed?

@b3lc0d3
Copy link

b3lc0d3 commented Dec 4, 2018

#1301 , so it's not allowed

@wodim
Copy link
Author

wodim commented Dec 4, 2018

Wow, that is terrible.

@thinkerou
Copy link
Member

expected, thanks! you should re-write your route.

@wodim
Copy link
Author

wodim commented Dec 5, 2018

Saying it's "expected" makes it double terrible, because it means you will never get around to fix it.

There is no way Gin should confuse Bleble with Blibli: Bleble has two slashes, and Blibli has three!

In the end I had to write my own router like this:

router.GET("/", ViewHome)
router.GET("/:first", ViewRouterOne)
router.GET("/:first/:second", ViewRouterTwo)
router.GET("/:first/:second/:third", ViewRouterThree)
router.GET("/:first/:second/:third/:fourth", ViewRouterFour)

Then from those functions you can redirect requests to the correct view functions. I hope this is useful to someone.

@safwanolaimat
Copy link

how this routes cause conflict

pGroup.POST("/fork", controllers.Fork)
pGroup.POST("/:id/process", controllers.processN)

@marloncristian
Copy link

Am I the only one who doesn't understand why something so basic is not implemented in gin?

@wodim
Copy link
Author

wodim commented Mar 21, 2020

#2016 (comment)

@LaysDragon
Copy link

LaysDragon commented Mar 25, 2020

Am I the only one who doesn't understand why something so basic is not implemented in gin?

me either,such basic functional route supported by most http server in the world but not in gin
therefore,I have to rewrite the old openapi spec to make path can work with gin

@insomnius
Copy link

How can i fix this? Where should i start to contribute to fix this?

@LaysDragon
Copy link

How can i fix this? Where should i start to contribute to fix this?

It's httprouter's problem that gin currently based on
checkout this issue #2016

@vishnukvmd vishnukvmd mentioned this issue May 9, 2020
chrisk314 added a commit to chrisk314/riotjs-nginx-example-app that referenced this issue May 20, 2020
Note: gin router has some very serious limitations which mean that
it does not work with some typical rest route patterns. See e.g.
gin-gonic/gin#1681
L1ghtman2k added a commit to ScoreTrak/Web that referenced this issue Jul 27, 2020
@ridwanakf
Copy link

is this limitation still persist now?

@appcypher
Copy link

Wow! Gin routing pattern matching is a mess. Now I have to refactor my app to use another framework.

@shivamganwani
Copy link

shivamganwani commented Jan 9, 2023

@appleboy

Member
appleboy commented on Apr 8, 2021

bump to v1.7.0 version. See https://github.com/gin-gonic/gin/releases/tag/v1.7.0

Fix!!

@appleboy
Copy link
Member

appleboy commented Jan 9, 2023

@shivamganwani Thank you for classifying.

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