update to use static assets
This commit is contained in:
@@ -26,12 +26,9 @@ func (s *Server) RegisterRoutes(assets embed.FS) http.Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) handleAssets(mux *http.ServeMux, assets embed.FS) {
|
func (s *Server) handleAssets(mux *http.ServeMux, assets embed.FS) {
|
||||||
fileServer := http.FileServer(http.FS(assets))
|
mux.Handle("/assets/",
|
||||||
mux.Handle("/assets/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
http.StripPrefix("/assets/",
|
||||||
// Optionally set long-term caching headers for static assets
|
http.FileServer(http.Dir("pkg/web/assets"))))
|
||||||
//w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")
|
|
||||||
fileServer.ServeHTTP(w, r)
|
|
||||||
}))
|
|
||||||
|
|
||||||
mux.HandleFunc("/robots.txt", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("/robots.txt", func(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Cache-Control", "no-cache")
|
w.Header().Set("Cache-Control", "no-cache")
|
||||||
|
|||||||
Reference in New Issue
Block a user