1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-12 05:20:26 +00:00

Fix wrong mime-type

This commit is contained in:
bouncepaw 2020-11-03 00:24:50 +05:00
parent efa267db98
commit cb52d95882
2 changed files with 13 additions and 12 deletions

View File

@ -76,7 +76,7 @@ func handlerText(w http.ResponseWriter, rq *http.Request) {
hyphaName := HyphaNameFromRq(rq, "text")
if data, ok := HyphaStorage[hyphaName]; ok {
log.Println("Serving", data.textPath)
w.Header().Set("Content-Type", "text/plain")
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
http.ServeFile(w, rq, data.textPath)
}
}

23
mime.go
View File

@ -27,17 +27,18 @@ func MimeToExtension(mime string) string {
func ExtensionToMime(ext string) string {
mm := map[string]string{
"bin": "application/octet-stream",
"jpg": "image/jpeg",
"gif": "image/gif",
"png": "image/png",
"webp": "image/webp",
"svg": "image/svg+xml",
"ico": "image/x-icon",
"ogg": "application/ogg",
"webm": "video/webm",
"mp3": "audio/mp3",
"mp4": "video/mp4",
".bin": "application/octet-stream",
".jpg": "image/jpeg",
".jpeg": "image/jpeg",
".gif": "image/gif",
".png": "image/png",
".webp": "image/webp",
".svg": "image/svg+xml",
".ico": "image/x-icon",
".ogg": "application/ogg",
".webm": "video/webm",
".mp3": "audio/mp3",
".mp4": "video/mp4",
}
if mime, ok := mm[ext]; ok {
return mime