9 "go.stargrave.org/godlighty"
12 const MIMEDir = "mime"
18 CompressibleMIMEBundles = map[string]struct{}{
20 "playlist": struct{}{},
21 "subtitle": struct{}{},
26 CompressibleMIMEExts = []string{
36 func parseMIME(p string) map[string]string {
37 tsv, err := mimes.ReadFile(path.Join(MIMEDir, p))
41 m := make(map[string]string)
42 for _, line := range strings.Split(string(tsv), "\n") {
43 if len(line) == 0 || line[0] == '#' {
46 cols := strings.SplitN(line, "\t", 2)
53 entries, err := mimes.ReadDir(MIMEDir)
57 for _, entry := range entries {
58 bundle := entry.Name()
59 _, allCompressible := CompressibleMIMEBundles[bundle]
60 for ext, mediaType := range parseMIME(bundle) {
61 godlighty.ContentTypes[ext] = mediaType
63 godlighty.CompressibleContentTypes[mediaType] = struct{}{}
67 CompressibleMIMEBundles = nil
68 for _, ext := range CompressibleMIMEExts {
69 mediaType := godlighty.ContentTypes[ext]
70 godlighty.CompressibleContentTypes[mediaType] = struct{}{}
72 CompressibleMIMEExts = nil