Skip to content

class HTTP::StaticFileHandler
inherits Reference

A handler that lists directories and serves files under a given public directory.

This handler can send precompressed content, if the client accepts it, and a file with the same name and .gz extension appended is found in the same directory. Precompressed files are only served if they are newer than the original file.

Included modules

HTTP::Handler

Direct known subclasses

Crystal::Playground::PathStaticFileHandler

Class methods

.new(public_dir : String, fallthrough = true, directory_listing = true)

Creates a handler that will serve files in the given public_dir, after expanding it (using File#expand_path).

If fallthrough is false, this handler does not call next handler when request method is neither GET or HEAD, then serves 405 Method Not Allowed. Otherwise, it calls next handler.

If directory_listing is false, directory listing is disabled. This means that paths matching directories are ignored and next handler is called.

View source

Methods

#call(context)

View source