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

Named parameter in the beginning of route is producing an wildcard route conflicts with existing children in path error #332

Open ericreis opened 3 years ago

ericreis commented 3 years ago

I have the two following routes declared in my application:

router := httprouter.New()
router.Handler("GET", "/meta/healthcheck", http.HandlerFunc(rts.HealthCheck))
router.Handler("GET", "/:an/pricing/prices/:sku/computed/:priceTable", http.HandlerFunc(rts.ComputePrice))

However, this is producing the following error:

panic: wildcard route ':an' conflicts with existing children in path '/:an/pricing/prices/:sku/computed/:priceTable'

From my understanding, I can't have both a parameter and a static value in the same path position, but I think this shouldn't be an issue.

giuliodambrosio commented 3 years ago

I think this is a duplicate for https://github.com/julienschmidt/httprouter/issues/183