So I am trying to setup my router to respond to /users
and /users/{userId}
so I tried this code:
usersRouter := router.PathPrefix("/users").Subrouter()
usersRouter.HandleFunc("", users.GetUsersRoute).Methods("GET")
usersRouter.HandleFunc("/{userId:[0-9]*}", users.GetUserRoute).Methods("GET")
The issue is that I get a 404 error when I go to /users
(but is does respond to /users/
) If I do:
router.HandleFunc("/users", users.GetUsersRoute).Methods("GET")
router.HandleFunc("/users/{userId:[0-9]*}", users.GetUserRoute).Methods("GET")
It works like I want it to.
Is there any way to get the URLs to work like I want with Subrouters?