hyperlane-plugin-static-files 22.14.1

A high-performance static file server plugin for the Hyperlane framework with canonicalized path-traversal protection, built-in FileExtension MIME detection, 64-way sharded hot-file cache, precompressed .br/.gz sidecars, ETag/304 conditional validation, RFC 9110 Range 206/416 support, and SPA fallback.
Documentation
/// Default URL mount prefix served by [`crate::StaticFilesHook`].
pub const DEFAULT_STATIC_MOUNT_PREFIX: &str = "/";

/// Default directory index filename.
pub const DEFAULT_STATIC_INDEX_FILE: &str = "index.html";

/// Default `Cache-Control` header applied to served static files.
pub const DEFAULT_STATIC_CACHE_CONTROL: &str = "public, max-age=3600";

/// Default maximum total memory budget for the sharded hot-file cache (32 MiB).
pub const DEFAULT_STATIC_MAX_CACHE_BYTES: usize = 32 * 1024 * 1024;

/// Default maximum single file size eligible for in-memory hot caching (1 MiB).
pub const DEFAULT_STATIC_MAX_FILE_CACHE_BYTES: usize = 1024 * 1024;

/// Number of independent hot-file cache shards (`64`, power of two).
pub(crate) const STATIC_CACHE_SHARDS: usize = 64;

/// `Accept-Ranges` value advertising byte-range support.
pub(crate) const ACCEPT_RANGES_BYTES: &str = "bytes";

/// `Range` header unit prefix.
pub(crate) const RANGE_BYTES_PREFIX: &str = "bytes=";

/// `Content-Encoding` token for Brotli precompressed sidecars.
pub(crate) const ENCODING_BR: &str = "br";

/// `Content-Encoding` token for Gzip precompressed sidecars.
pub(crate) const ENCODING_GZIP: &str = "gzip";

/// File extension suffix for Brotli sidecar assets.
pub(crate) const SIDECAR_BR_EXT: &str = ".br";

/// File extension suffix for Gzip sidecar assets.
pub(crate) const SIDECAR_GZ_EXT: &str = ".gz";

/// `Vary` token emitted when serving negotiated precompressed sidecars.
pub(crate) const VARY_ACCEPT_ENCODING: &str = "Accept-Encoding";

/// Lowercase hexadecimal alphabet used for stack-allocated strong ETag formatting.
pub(crate) const HEX_DIGITS: &[u8; 16] = b"0123456789abcdef";

/// Bitmask flag indicating client accepts Brotli content encoding.
pub(crate) const ENCODING_MASK_BR: u8 = 0b01;

/// Bitmask flag indicating client accepts Gzip content encoding.
pub(crate) const ENCODING_MASK_GZIP: u8 = 0b10;

/// Prefix for RFC 9110 `Content-Range` satisfied partial responses.
pub(crate) const CONTENT_RANGE_BYTES_PREFIX: &str = "bytes ";

/// Prefix for RFC 9110 `Content-Range` unsatisfiable (`416`) responses.
pub(crate) const CONTENT_RANGE_UNSAT_PREFIX: &str = "bytes */";

/// Stack buffer capacity in bytes for formatting `Content-Range` headers without heap allocation.
pub(crate) const CONTENT_RANGE_STACK_CAP: usize = 64;

/// Stack buffer capacity in bytes for lowercasing file extensions during MIME lookup.
pub(crate) const MIME_EXT_STACK_CAP: usize = 24;

/// Stack buffer capacity in bytes for formatting file ETags (`"<hex>-<hex>"`).
pub(crate) const ETAG_STACK_CAP: usize = 40;

/// Weak ETag prefix stripped during weak comparison.
pub(crate) const WEAK_ETAG_PREFIX: &str = "W/";

/// Wildcard `If-None-Match` token.
pub(crate) const ETAG_WILDCARD: &str = "*";