When I'm using chi for a project with swagger-ui, I feel it is not so convenient for serving static files. What about adding the static file serving feature like this:
func (mx *Mux) Static(path, root string) {
fs := http.StripPrefix(path, http.FileServer(http.Dir(root)))
mx.Get(path+"/*", func(w http.ResponseWriter, r *http.Request) {
fs.ServeHTTP(w, r)
})
}
@netsharec I see what you mean. I'll add this function later today.
Please allow it to take an http.FileSystem instead of directory so we can serve static files from memory. I often do that along with go-bindata.
@fiorix good call
Merged in #36 - see new mux.FileServer(path string, root http.FileSystem) method.. example usage: https://github.com/pressly/chi/blob/master/mux_test.go#L734-L743
@pkieltyka: Is it correct that this functionality doesn't exist anymore, but instead you have to follow this example?
yep, thats correct
Most helpful comment
Merged in #36 - see new
mux.FileServer(path string, root http.FileSystem)method.. example usage: https://github.com/pressly/chi/blob/master/mux_test.go#L734-L743