Gin: "wildcard route conflicts with existing children"

Created on 4 Dec 2018  路  11Comments  路  Source: gin-gonic/gin

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?

Most helpful comment

Wow, that is terrible.

All 11 comments

Wow, that is terrible.

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

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.

how this routes cause conflict

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

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

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

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

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 https://github.com/gin-gonic/gin/issues/2016

is this limitation still persist now?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sofish picture sofish  路  3Comments

mastrolinux picture mastrolinux  路  3Comments

iiinsomnia picture iiinsomnia  路  3Comments

oryband picture oryband  路  3Comments

gplume picture gplume  路  3Comments