From 6ae09962ad333e4b7e5b533a867a64fb3ff6d143 Mon Sep 17 00:00:00 2001 From: bel Date: Mon, 13 Apr 2020 13:00:30 +0000 Subject: [PATCH] More content types --- main.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index fe8ad62..5cb15d5 100755 --- a/main.go +++ b/main.go @@ -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") } }