class Static
A middleware which serves static files from the specified root directory.
Nested
Definitions
MIME_TYPES = {...}
Default mime-types which are common for files served over HTTP:
Implementation
MIME_TYPES = {
:xiph => {
"ogx" => "application/ogg",
"ogv" => "video/ogg",
"oga" => "audio/ogg",
"ogg" => "audio/ogg",
"spx" => "audio/ogg",
"flac" => "audio/flac",
"anx" => "application/annodex",
"axa" => "audio/annodex",
"xspf" => "application/xspf+xml",
},
:media => [
:xiph, "mp3", "mp4", "wav", "aiff", "aac", "webm", "mov", "avi", "wmv", "mpg"
],
:text => [
"html", "css", "js", ["map", "application/json"], "txt", "rtf", "xml", "pdf"
],
:fonts => [
"otf", ["eot", "application/vnd.ms-fontobject"], "ttf", "woff", "woff2"
],
:archive => [
"zip", "tar", "tgz", "tar.gz", "tar.bz2", ["dmg", "application/x-apple-diskimage"],
["torrent", "application/x-bittorrent"]
],
:images => [
"png", "gif", "jpeg", "tiff", "svg", "webp"
],
:default => [
:media, :text, :archive, :images, :fonts
]
}
def initialize(app, root: Utopia::default_root, types: MIME_TYPES[:default], cache_control: DEFAULT_CACHE_CONTROL)
Implementation
def initialize(app, root: Utopia::default_root, types: MIME_TYPES[:default], cache_control: DEFAULT_CACHE_CONTROL)
@app = app
@root = root
@extensions = MimeTypeLoader.extensions_for(types)
@cache_control = cache_control
end