I have the following code:
r := mux.NewRouter()
r.HandleFunc("/", homeHandler)
r.HandleFunc("/login", loginHandler)
admin.Handle(r.PathPrefix("/admin").Subrouter())
....
http.Handle("/", r)
http.ListenAndServer(":1234", nil)
In admin package, I have:
func Handle(router *mux.Router) {
router.HandleFunc("/", adminHandler)
router.HandleFunc("/add", addGameHandler)
router.HandleFunc("/finish/{id}", finishGameHandler)
}
So, when I attempt to reach "/admin", the server calls homeHandler?? However, if I try with "/admin/add" or "admin/finish/123", the server calls the correct handlers. What's the reason? What I am doing wrong?