More content types

master v0.7
bel 2020-04-13 13:00:30 +00:00
parent 17e3e21e56
commit 6ae09962ad
1 changed files with 11 additions and 1 deletions

12
main.go
View File

@ -204,7 +204,7 @@ func toRealPath(p string) string {
}
func setContentTypeIfMedia(w http.ResponseWriter, r *http.Request) {
switch path.Ext(r.URL.Path) {
switch strings.ToLower(path.Ext(r.URL.Path)) {
case ".mp4":
w.Header().Set("Content-Type", "video/mp4")
case ".webm":
@ -215,5 +215,15 @@ func setContentTypeIfMedia(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "audio/mpeg3")
case ".epub", ".mobi":
w.Header().Set("Content-Disposition", "attachment")
case ".jpg", ".jpeg":
w.Header().Set("Content-Type", "image/jpeg")
case ".gif":
w.Header().Set("Content-Type", "image/gif")
case ".png":
w.Header().Set("Content-Type", "image/png")
case ".ico":
w.Header().Set("Content-Type", "image/x-icon")
case ".svg":
w.Header().Set("Content-Type", "image/svg+xml")
}
}