pub struct AppState {
pub manifest: Arc<Manifest>,
pub matcher: Router<usize>,
pub pool: Arc<WorkerPool>,
pub cdn_base_url: Option<String>,
pub fallback_dir: Option<PathBuf>,
pub cache: Arc<ResponseCache>,
pub generations: Arc<Generations>,
pub session: Option<Arc<dyn SessionResolver>>,
pub login_url: Option<String>,
pub metrics: Arc<Metrics>,
}Expand description
Shared state accessed by every request handler.
Fields§
§manifest: Arc<Manifest>§matcher: Router<usize>matchit router mapping URL patterns → index into manifest.routes.
pool: Arc<WorkerPool>§cdn_base_url: Option<String>If set, Mode 1 routes redirect here: {cdn_base_url}{path}.
fallback_dir: Option<PathBuf>Local fallback directory for Mode 1 when no CDN is configured.
cache: Arc<ResponseCache>Mode 2 LRU response cache.
generations: Arc<Generations>Source generation provider (cache-key input 6).
session: Option<Arc<dyn SessionResolver>>Session resolver (None = sessions disabled; requires: ["user"]
routes then always redirect/401).
login_url: Option<String>Where to 302 a request that lacks a session on a requires: ["user"]
route. ?next=<original-url> is appended. None → 401.
metrics: Arc<Metrics>Prometheus metrics registry, shared with the /metrics handler and the
worker pool (restarting gauge).
Implementations§
Source§impl AppState
impl AppState
pub fn new( manifest: Arc<Manifest>, pool: Arc<WorkerPool>, cdn_base_url: Option<String>, fallback_dir: Option<PathBuf>, ) -> Self
pub fn with_metrics(self, metrics: Arc<Metrics>) -> Self
pub fn with_cache(self, cache: Arc<ResponseCache>) -> Self
pub fn with_generations(self, generations: Arc<Generations>) -> Self
pub fn with_session(self, session: Arc<dyn SessionResolver>) -> Self
pub fn with_login_url(self, login_url: Option<String>) -> Self
Auto Trait Implementations§
impl !Freeze for AppState
impl !RefUnwindSafe for AppState
impl !UnwindSafe for AppState
impl Send for AppState
impl Sync for AppState
impl Unpin for AppState
impl UnsafeUnpin for AppState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more