julienschmidt / httprouter

A high performance HTTP request router that scales well
https://pkg.go.dev/github.com/julienschmidt/httprouter
BSD 3-Clause "New" or "Revised" License
16.64k stars 1.47k forks source link

wildcard conflict should panic but doesn't #172

Closed mbertschler closed 5 years ago

mbertschler commented 7 years ago

This code panics: panic: catch-all routes are only allowed at the end of the path in path '/api/*rest/two'

router := httprouter.New()
router.GET("/api/*rest/two", handler)
router.GET("/api/*rest", handler)

But this one doesn't.

router := httprouter.New()
router.GET("/api/*rest", handler)
router.GET("/api/*rest/two", handler)

As far as I understand it the router should behave the same in the two cases, or am I missing something?

julienschmidt commented 7 years ago

In the second case one of the two routes is unreachable. However, this does not seem to be detected during registration, which is a bug.

chahat-arora commented 5 years ago

@julienschmidt Hey, any progress on this?