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