diff options
Diffstat (limited to 'pkg/handler/static/handler.go')
-rw-r--r-- | pkg/handler/static/handler.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/pkg/handler/static/handler.go b/pkg/handler/static/handler.go index a8b4583..5155068 100644 --- a/pkg/handler/static/handler.go +++ b/pkg/handler/static/handler.go @@ -2,8 +2,11 @@ package static import ( "io/fs" + "mime" "net/http" + "path/filepath" + "git.gabrielgio.me/cerrado/pkg/ext" "git.gabrielgio.me/cerrado/static" ) @@ -14,8 +17,12 @@ func ServeStaticHandler() (func(w http.ResponseWriter, r *http.Request), error) } return func(w http.ResponseWriter, r *http.Request) { - f := r.PathValue("file") - + var ( + f = r.PathValue("file") + e = filepath.Ext(f) + m = mime.TypeByExtension(e) + ) + ext.SetMIME(w, m) http.ServeFileFS(w, r, staticFs, f) }, nil } |