Menu
  • HOME
  • TAGS

How to Use ServeMux with ServerConn?

http,go,server,servemux

I would avoid doing this altogether if at all possible. Mixing protocols on the same connection is bound to lead to hard-to-trace bugs, and unexpected behavior. If you really want to do it, and have all the http/1.1 mechanisms work correctly, leave as much as possible to the http package....

Gorilla Mux to handle curl request

go,gorilla,gorilla-toolkit,servemux

You may try to add Queries to your router, in that case you will have all vars in one map. router.Methods("GET").Path("/api/myapiname/{version}").Queries("number", "{number:[0-9]+}", "target", "{target:[^&]+}", "message", "{message:[^&]+}").HandlerFunc(apihandler) func apihandler(rw http.ResponseWriter, q *http.Request) { vars := mux.Vars(q) log.Println(vars["version"]) log.Println(vars("number")) log.Println(vars("target")) log.Println(vars("message")) } ...