Module: Utopia::Static

Defined in:
lib/utopia/static/local_file.rb,
lib/utopia/static.rb,
lib/utopia/static/middleware.rb,
lib/utopia/static/mime_types.rb

Overview

A middleware which serves static files from the specified root directory.

Defined Under Namespace

Classes: LocalFile, Middleware, MimeTypeLoader

Constant Summary collapse

DEFAULT_CACHE_CONTROL =
"public, max-age=3600".freeze
MIME_TYPES =

Default mime-types which are common for files served over HTTP:

{
  :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", "m3u8", "ts"
  ],
  :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
  ]
}

Class Method Summary collapse

Class Method Details

.newObject



10
11
12
# File 'lib/utopia/static.rb', line 10

def self.new(...)
  Middleware.new(...)
end