repos / pico

pico services mono repo
git clone https://github.com/picosh/pico.git

pico / pkg / shared / mime
Eric Bower  ·  2025-05-24

mime.go

 1package mime
 2
 3import "path/filepath"
 4
 5func GetMimeType(fpath string) string {
 6	ext := filepath.Ext(fpath)
 7	switch ext {
 8	case ".svg":
 9		return "image/svg+xml"
10	case ".css":
11		return "text/css"
12	case ".js":
13		return "text/javascript"
14	case ".ico":
15		return "image/x-icon"
16	case ".pdf":
17		return "application/pdf"
18	case ".htm":
19	case ".html":
20		return "text/html"
21	case ".jpeg":
22	case ".jpg":
23		return "image/jpeg"
24	case ".png":
25		return "image/png"
26	case ".gif":
27		return "image/gif"
28	case ".webp":
29		return "image/webp"
30	case ".otf":
31		return "font/otf"
32	case ".woff":
33		return "font/woff"
34	case ".woff2":
35		return "font/woff2"
36	case ".ttf":
37		return "font/ttf"
38	case ".md":
39		return "text/markdown; charset=UTF-8"
40	case ".map":
41	case ".json":
42		return "application/json"
43	case ".rss":
44		return "application/rss+xml"
45	case ".atom":
46		return "application/atom+xml"
47	case ".webmanifest":
48		return "application/manifest+json"
49	case ".xml":
50		return "application/xml"
51	case ".xsl":
52		return "application/xml"
53	case ".avif":
54		return "image/avif"
55	case ".heif":
56		return "image/heif"
57	case ".heic":
58		return "image/heif"
59	case ".opus":
60		return "audio/opus"
61	case ".wav":
62		return "audio/wav"
63	case ".mp3":
64		return "audio/mpeg"
65	case ".mp4":
66		return "video/mp4"
67	case ".mpeg":
68		return "video/mpeg"
69	case ".wasm":
70		return "application/wasm"
71	case ".opml":
72		return "text/x-opml"
73	case ".eot":
74		return "application/vnd.ms-fontobject"
75	case ".yaml":
76	case ".yml":
77		return "text/x-yaml"
78	case ".zip":
79		return "application/zip"
80	case ".rar":
81		return "application/vnd.rar"
82	case ".txt":
83		return "text/plain"
84	}
85
86	return "text/plain"
87}