module StaticAssets

Overview

Production static asset HTTP::Handler for Crystal.

Provides immutable caching defaults tuned for Vite fingerprinted builds, ETag/Last-Modified conditional 304 responses, Brotli/Gzip precompressed content negotiation, byte Range/206 support, and optional in-memory storage.

Defined in:

static_assets.cr
static_assets/conditional.cr
static_assets/config.cr
static_assets/encoding.cr
static_assets/handler.cr
static_assets/mime_types.cr
static_assets/range.cr
static_assets/store.cr
static_assets/version.cr

Constant Summary

VERSION = {{ (`shards version /home/runner/work/static-assets/static-assets/src/static_assets`).chomp.stringify }}

Class Method Summary

Macro Summary

Class Method Detail

def self.handler(public_dir : String = "public", url_prefix : String = "/", store : Store | Nil = nil, & : Config -> ) : Handler #

Builds a StaticAssets::Handler configured via a Config block.


[View source]
def self.handler(public_dir : String = "public", url_prefix : String = "/", store : Store | Nil = nil) : Handler #

Builds a StaticAssets::Handler with explicit directories or defaults.


[View source]

Macro Detail

macro embed_file(path) #

Embeds a file at compile time as Bytes for use with MemoryStore#add.


[View source]