0
votes

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?

1
What does "/admin/" do?li x
log.Println("admin")Asen Valchev
Sorry I meant what happens when you navigate to /admin with a forward slash at the end '/admin/'li x
Same. Calls homeHandler.Asen Valchev

1 Answers

0
votes

Well, I have tried with another browser and it worked... So, I cleaned the cookies, history and other stuff in the main browser and that fixed the problem. I still don't know why... Maybe is something about the cookie that I create for keeping login data? Something about the cookie's path?