module Static

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

Classes and Modules

class LocalFile

Represents a local static resource and constructs responses for it.

class Middleware < Protocol::HTTP::Middleware

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

Provider
class MimeTypeLoader

A class to assist with loading mime-type metadata.

Definitions

MIME_TYPES = {...}

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

Implementation

MIME_TYPES = {
	:xiph => [
		"ogx", "ogv", "oga", "ogg", "spx", "flac", "xspf"
	],
	:media => [
		:xiph, "mp3", "mp4", "wav", "aiff", "aac", "webm", "weba", "mov", "avi", "wmv", "mpg", "m3u8", "ts"
	],
	:scripts => [
		"js", "mjs", "wasm"
	],
	:text => [
		"html", "css", "map", "txt", "rtf", "xml", "pdf"
	],
	:fonts => [
		"otf", "eot", "ttf", "woff", "woff2"
	],
	:archive => [
		"zip", "tar", "tgz", "gz", "bz2", "dmg", "torrent"
	],
	:images => [
		"png", "gif", "jpeg", "tiff", "svg", "webp"
	],
	:default => [
		:media, :scripts, :text, :archive, :images, :fonts
	]
}

def self.new(...)

Construct static-file middleware.

Signature

returns Static::Middleware

The static-file middleware.

Implementation

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