-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmimemap.go
39 lines (31 loc) · 836 Bytes
/
mimemap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import "mime"
type MimeMap map[string]string
func NewMimeMapWithDefaults() MimeMap {
return MimeMap{
".css": "text/css; charset=utf-8",
".htm": "text/html; charset=utf-8",
".html": "text/html; charset=utf-8",
".js": "text/javascript; charset=utf-8",
".mjs": "text/javascript; charset=utf-8",
".txt": "text/plain; charset=utf-8",
".gif": "image/gif",
".jpeg": "image/jpeg",
".jpg": "image/jpeg",
".png": "image/png",
".svg": "image/svg+xml",
".webp": "image/webp",
".woff": "font/woff",
".woff2": "font/woff2",
".json": "application/json",
".pdf": "application/pdf",
".xml": "application/xml",
".zip": "application/zip",
}
}
func (mm MimeMap) FindType(ext string) string {
if mType, found := mm[ext]; found {
return mType
}
return mime.TypeByExtension(ext)
}