Skip to main content

hyperlane_plugin_static_files/
lib.rs

1//! hyperlane-plugin-static-files
2//!
3//! High-performance static file serving plugin for Hyperlane with path-traversal
4//! defense, Hyperlane [`FileExtension`] MIME detection, 64-way sharded hot-file
5//! caching, `.br`/`.gz` precompressed sidecars, `ETag`/`304`, RFC 9110 `Range`
6//! (`206`/`416`), and SPA fallback.
7
8mod r#const;
9mod r#fn;
10mod r#impl;
11mod r#static;
12mod r#struct;
13mod r#type;
14
15#[cfg(test)]
16#[path = "../tests/mod.rs"]
17mod tests;
18
19pub use {r#const::*, r#fn::*, r#struct::*};
20
21pub(crate) use {r#static::*, r#type::*};
22
23use std::{
24    array::from_fn,
25    ffi::OsString,
26    fs::{Metadata, canonicalize},
27    hash::Hasher,
28    io,
29    path::{Component, Path, PathBuf},
30    str::Split,
31    sync::{
32        Arc, OnceLock, RwLock,
33        atomic::{AtomicUsize, Ordering},
34    },
35    time::{Duration, SystemTime, UNIX_EPOCH},
36};
37
38use {
39    hyperlane::{
40        ACCEPT_ENCODING, ACCEPT_RANGES, APPLICATION_OCTET_STREAM, CACHE_CONTROL, CONTENT_ENCODING,
41        CONTENT_RANGE, CONTENT_TYPE, Context, ETAG, FileExtension, HashMapXxHash3_64, HttpStatus,
42        IF_NONE_MATCH, RANGE, Response, ResponseData, ResponseError, ServerHook, Status, Stream,
43        VARY, XxHash3_64, hash_map_xx_hash3_64, tokio::fs,
44    },
45    lombok_macros::*,
46};