aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler/static/handler.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/handler/static/handler.go')
-rw-r--r--pkg/handler/static/handler.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/pkg/handler/static/handler.go b/pkg/handler/static/handler.go
index 5155068..0973d75 100644
--- a/pkg/handler/static/handler.go
+++ b/pkg/handler/static/handler.go
@@ -10,19 +10,21 @@ import (
"git.gabrielgio.me/cerrado/static"
)
-func ServeStaticHandler() (func(w http.ResponseWriter, r *http.Request), error) {
+func ServeStaticHandler() (ext.ErrorRequestHandler, error) {
staticFs, err := fs.Sub(static.Static, ".")
if err != nil {
return nil, err
}
- return func(w http.ResponseWriter, r *http.Request) {
+ return func(w http.ResponseWriter, r *http.Request) error {
var (
f = r.PathValue("file")
e = filepath.Ext(f)
m = mime.TypeByExtension(e)
)
ext.SetMIME(w, m)
+ w.Header().Add("Cache-Control", "immutable")
http.ServeFileFS(w, r, staticFs, f)
+ return nil
}, nil
}