9 "go.stargrave.org/godlighty"
12 const MIMEDir = "mime"
19 type MIMEEntry struct {
25 func parseMIME(p string) []MIMEEntry {
26 tsv, err := mimes.ReadFile(path.Join(MIMEDir, p))
30 entries := make([]MIMEEntry, 0)
31 for _, line := range strings.Split(string(tsv), "\n") {
32 if len(line) == 0 || line[0] == '#' {
35 cols := strings.Split(line, "\t")
36 entry := MIMEEntry{ext: cols[0], mediaType: cols[1]}
37 if len(cols) > 2 && cols[2] == "c" {
38 entry.compressible = true
40 entries = append(entries, entry)
46 entries, err := mimes.ReadDir(MIMEDir)
50 for _, entry := range entries {
51 bundle := entry.Name()
52 for _, e := range parseMIME(bundle) {
53 godlighty.ContentTypes[e.ext] = e.mediaType
55 godlighty.CompressibleContentTypes[e.mediaType] = struct{}{}