I'm using the mux package which seems to work quite well except that it doesn't seem to support complex routes or at least I don't get it how it does. I have several routes as following:
router := mux.NewRouter()
router.HandleFunc("/{productid}/{code}", product)
router.HandleFunc("/{user}", userHome)
router.HandleFunc("/search/price", searchPage)
So I have two questions:
How can I define a wildcard route such /search/price/* so that a request such /search/price/29923/rage/200/color=red can match it ?
Is it possible to add custom conditions to an existing route ? e.g. if the route is
/{productid}/{code}
and function x returnstrue
, use thishandlerTrue
, if it returnsfalse
usehandlerFalse
.
I've tried to add something like .MatcherFunc(myfunction(ip)bool)
to the route but it complains that the router has no such method.
Currently I'm handling the 'custom' conditions inside the handler.