parent
17e3e21e56
commit
6ae09962ad
12
main.go
12
main.go
|
|
@ -204,7 +204,7 @@ func toRealPath(p string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func setContentTypeIfMedia(w http.ResponseWriter, r *http.Request) {
|
func setContentTypeIfMedia(w http.ResponseWriter, r *http.Request) {
|
||||||
switch path.Ext(r.URL.Path) {
|
switch strings.ToLower(path.Ext(r.URL.Path)) {
|
||||||
case ".mp4":
|
case ".mp4":
|
||||||
w.Header().Set("Content-Type", "video/mp4")
|
w.Header().Set("Content-Type", "video/mp4")
|
||||||
case ".webm":
|
case ".webm":
|
||||||
|
|
@ -215,5 +215,15 @@ func setContentTypeIfMedia(w http.ResponseWriter, r *http.Request) {
|
||||||
w.Header().Set("Content-Type", "audio/mpeg3")
|
w.Header().Set("Content-Type", "audio/mpeg3")
|
||||||
case ".epub", ".mobi":
|
case ".epub", ".mobi":
|
||||||
w.Header().Set("Content-Disposition", "attachment")
|
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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue