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    borrow::Cow,
26    ffi::{OsStr, OsString},
27    fs::{Metadata, canonicalize},
28    hash::Hasher,
29    io,
30    path::{Component, Path, PathBuf},
31    str::{Split, from_utf8},
32    sync::{
33        Arc, OnceLock, RwLock, RwLockReadGuard,
34        atomic::{AtomicUsize, Ordering},
35    },
36    time::{Duration, SystemTime, UNIX_EPOCH},
37};
38
39use {
40    hyperlane::{
41        ACCEPT_ENCODING, ACCEPT_RANGES, APPLICATION_OCTET_STREAM, CACHE_CONTROL, CONTENT_ENCODING,
42        CONTENT_RANGE, CONTENT_TYPE, Context, EMPTY_STR, ETAG, FileExtension, HashMapXxHash3_64,
43        HttpStatus, IF_NONE_MATCH, RANGE, Request, RequestHeadersValue, Response, ResponseData,
44        ResponseError, ServerHook, Status, Stream, VARY, XxHash3_64, hash_map_xx_hash3_64,
45        tokio::fs,
46    },
47    lombok_macros::*,
48};