I'm having Problems setting up my static file serving for a Subdomain using the gorilla/mux package.

I have a mux router set up that has some routes for other projects and now I want to serve static content at static.example.com. I tried to implement it in a route with the standard file server, but I am not sure how to do that. The server is also https only.

I already tried some approaches with .Host() at the end of the route and the http.FileServer, like this:

r.PathPrefix("/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir(usr.HomeDir+"/static/")))).Host("static.example.com")

0 Answers