I had a look a this question Serving static content with a root URL with the Gorilla toolkit and used the answer from there successfully.
I, though, want to declare explicitly which file I want to serve as static, for development purposes, like this:
router.PathPrefix("/style.css").Handler(http.FileServer(http.Dir("/usr/local/myproject/style.css")))
Which worked as expected too.
Now, I wonder, if it's a correct way to serve a single explicitly defined file or should I do it differently?
<url>/style.css/abc
? – JesuitismPathPrefix
you should usePath
router – Jesuitismhttp.ServeFile()
. See this answer for details: Include js file in Go template. – Nealneala