aboutsummaryrefslogtreecommitdiff
path: root/src/guff/mime-type.cr
blob: 8f06f12a156a62d0377e9c321b64a3fd3f832b6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Guff::MimeType
  TYPES = {
    ".js":    "text/javascript; charset=utf-8",
    ".css":   "text/css; charset=utf-8",
    ".html":  "text/html; charset=utf-8",
    ".png":   "image/png",
    ".jpeg":  "image/jpeg",
    ".jpg":   "image/jpeg",
    ".otf":   "application/vnd.ms-opentype",
    ".eot":   "application/vnd.ms-fontobject",
    ".svg":   "image/svg+xml",
    ".ttf":   "application/x-font-ttf",
    ".woff":  "application/font-woff",
    ".woff2": "application/font-woff",
  }

  def self.mime_type(path : String) : String
    TYPES[File.extname(path)]? || "application/octet-stream"
  end
end