Skip to content

Navigation Menu

Sign in
Sign up

Issue Serving files in Sub-Routes. #31

xnpltn started this conversation in General
Discussion options

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?

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /