fix content-type

This commit is contained in:
Nazar Kanaev 2020-06-30 23:24:39 +01:00
parent 6349e97fdf
commit a2f72a8c42

View File

@ -10,6 +10,7 @@ import (
"fmt"
"mime"
"strings"
"path/filepath"
)
func IndexHandler(rw http.ResponseWriter, req *http.Request) {
@ -33,7 +34,7 @@ func StaticHandler(rw http.ResponseWriter, req *http.Request) {
return
}
defer f.Close()
rw.Header().Set("Content-Type", mime.TypeByExtension(path))
rw.Header().Set("Content-Type", mime.TypeByExtension(filepath.Ext(path)))
io.Copy(rw, f)
}