8 "go.stargrave.org/godlighty"
11 const MIMEDir = "mime"
18 type MIMEEntry struct {
24 func parseMIME(p string) []MIMEEntry {
25 tsv, err := mimes.ReadFile(path.Join(MIMEDir, p))
29 entries := make([]MIMEEntry, 0)
30 for _, line := range strings.Split(string(tsv), "\n") {
31 if len(line) == 0 || line[0] == '#' {
34 cols := strings.Split(line, "\t")
35 entry := MIMEEntry{ext: cols[0], mediaType: cols[1]}
36 if len(cols) > 2 && cols[2] == "c" {
37 entry.compressible = true
39 entries = append(entries, entry)
45 entries, err := mimes.ReadDir(MIMEDir)
49 for _, entry := range entries {
50 bundle := entry.Name()
51 for _, e := range parseMIME(bundle) {
52 godlighty.ContentTypes[e.ext] = e.mediaType
54 godlighty.CompressibleContentTypes[e.mediaType] = struct{}{}