use super::*;
#[derive(Clone, Data, Debug, Eq, PartialEq)]
pub struct StaticFilesConfig {
pub(crate) root_dir: PathBuf,
pub(crate) mount_prefix: String,
pub(crate) index_file: String,
#[get(type(clone))]
pub(crate) spa_fallback: Option<String>,
pub(crate) cache_control: String,
#[get(type(copy))]
pub(crate) serve_precompressed: bool,
#[get(type(copy))]
pub(crate) allow_dotfiles: bool,
#[get(type(copy))]
pub(crate) max_cache_bytes: usize,
#[get(type(copy))]
pub(crate) max_file_cache_bytes: usize,
}
#[derive(Clone, Copy, Default)]
pub(crate) struct FxHasher {
pub(crate) state: u64,
}
#[repr(align(64))]
pub(crate) struct StaticCacheShard {
pub(crate) map: RwLock<StaticCacheShardMap>,
}
#[derive(Debug)]
pub(crate) struct CachedFile {
pub(crate) bytes: Arc<[u8]>,
pub(crate) etag: String,
pub(crate) content_type: &'static str,
pub(crate) content_encoding: Option<&'static str>,
pub(crate) wire_ok: OnceLock<Arc<[u8]>>,
pub(crate) wire_head: OnceLock<Arc<[u8]>>,
pub(crate) wire_304: OnceLock<Arc<[u8]>>,
}
#[derive(Clone, Debug)]
pub(crate) struct CachedRouteEntry {
pub(crate) raw: Arc<CachedFile>,
pub(crate) br: Option<Arc<CachedFile>>,
pub(crate) gz: Option<Arc<CachedFile>>,
}
pub(crate) struct StaticFilesRuntimeInner {
pub(crate) config: StaticFilesConfig,
pub(crate) canonical_root: PathBuf,
pub(crate) normalized_prefix: String,
pub(crate) cached_bytes: AtomicUsize,
pub(crate) cache_shards: Box<[StaticCacheShard; STATIC_CACHE_SHARDS]>,
}
#[derive(Clone)]
pub struct StaticFilesRuntime {
pub(crate) inner: Arc<StaticFilesRuntimeInner>,
}
#[derive(Clone)]
pub struct StaticFilesPlugin {
pub(crate) runtime: StaticFilesRuntime,
}
#[derive(Clone, Copy, Debug, Default)]
#[hyperlane::request_middleware(-55)]
pub struct StaticFilesHook;