With gorilla/mux you can use named routes : r := mux.NewRouter() r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler). Name("article") url, err := r.Get("article").URL("category", "technology", "id", "42")
Le lundi 14 novembre 2016 17:34:26 UTC+1, to...@hypr.nz a écrit : > > I believe I have done enough research (and attempts) that this should be > an easy answer: either it doesn't work that way or I've missed something > simple! Fingers crossed and thanks in advance. > > My goal is to render absolute URLs for my API—I can't get route libraries > (eg gorilla/mux) to do this even though they look to be able to do so. > > The first question, to render absolute URLs by reversing a route name, > which library should I really be using? I'm assuming one that hooks into > the http.Request, such as, gorilla/mux. > > Given I use gorilla/mux, how? I see in the source that it requires a Host > to be setting in the route registration but upon registration of a Host, it > never matches a route again. (I can't find a solution to this either which > suggests that I have something wrong in my thinking). > > I hope this is descriptive enough to know whether I am way off the mark or > need to provide more, detailed information. > > Thanks. Todd. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.