Trying to serve files using this piece of code .
func main(){
router:= mux.NewRouter()
// :8080/h/css/test.css
router.PathPrefix("/hx/").Handler(http.StripPrefix("/hx", http.FileServer(http.Dir("uploads/"))))
v1Router := router.PathPrefix("/v1").Subrouter()
// NOT WORKING
v1Router.PathPrefix("/hx/").Handler(http.StripPrefix("/hx", http.FileServer(http.Dir("uploads/"))))
http.ListenAndServe("localhost:8080", router)
}
It is working for the main router ( router ) but not for the sub-router (v1Router).
Any Idea how to solve the issue?
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment