Gorilla mux optional query values
I would just register your handler twice. router.Path(“/articles/{id:[0-9]+}”). Queries(“key”, “{[0-9]*?}”). HandlerFunc(YourHandler). Name(“YourHandler”) router.Path(“/articles/{id:[0-9]+}”).HandlerFunc(YourHandler) Here is a working program to demonstrate. Notice that I am using r.FormValue to get the query parameter. Note: make sure you have an up to date version go get -u github.com/gorilla/mux since a bug of query params not getting added the … Read more