gohttpserver/httpserver/handlestatic.go

15 lines
398 B
Go
Raw Normal View History

2020-10-29 00:47:37 +00:00
package httpserver
import (
"net/http"
)
func (s *server) staticHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// sadly, the route prefix needs to be reproduced here, so it knows
// how to convert the incoming request path to the appropriate
// embedded file path
http.StripPrefix("/s", http.FileServer(s.staticFiles.HTTPBox())).ServeHTTP(w, r)
}
}