I’ve got some problems to use gorilla mux within GAE.
When I try it, I’ve ‘404 page not found’. The rootHandler function is not called ( no traces generated)
Below is part of my code, any ideas?
thk in advance
...
func init() {
r := mux.NewRouter()
r.HandleFunc("/",rootHandler)
}
func rootHandler(w http.ResponseWriter, r *http.Request) {
var functionName = "rootHandler"
c := appengine.NewContext(r)
c.Infof(functionName+"-start")
defer c.Infof(functionName+"-end")
...
You have to route requests to your mux router.
httppackage hasDefaultServeMuxwhich is used by AppEngine, butmuxdoes not. (and it’s not registering its routes withnet/httpby itself)That is, all you have to do, is register your
muxrouter withnet/http:(straight from the docs)
Important part here is
http.Handle("/", r).