diff options
Diffstat (limited to 'roseh.moe.go')
| -rw-r--r-- | roseh.moe.go | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/roseh.moe.go b/roseh.moe.go index 55b3a72..32bcb6c 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -257,24 +257,10 @@ func buildStaticFileHashes() map[string]string { } func serveStaticFile(w http.ResponseWriter, r *http.Request, path string) { - f, err := staticFiles.Open(path) - if err != nil { - notFound(w, r) - return - } - defer f.Close() - stat, err := f.Stat() - if err != nil { - log.Printf("Warning: stat static file: %s", err) - http.Error(w, "internal error", http.StatusInternalServerError) - return - } - if stat.IsDir() { - notFound(w, r) - return + if eTag, ok := staticFileHashes[path]; ok { + w.Header().Set("ETag", eTag) } - w.Header().Set("ETag", staticFileHashes[path]) - http.ServeContent(w, r, path, time.Time{}, f.(io.ReadSeeker)) + http.ServeFileFS(w, r, staticFiles, path) } func static(w http.ResponseWriter, r *http.Request) { |
