pub struct App<S> { /* private fields */ }Expand description
A ling-http application: an axum Router pre-wired with the middleware
every service on this framework wants (tracing, timeouts, a body-size
cap, CORS), plus HTTPS serving helpers.
S is your application state (typically a struct holding a crate::db::Db
and any config), shared across handlers via axum’s State extractor.
Implementations§
Source§impl<S> App<S>
impl<S> App<S>
Sourcepub fn new() -> Self
pub fn new() -> Self
Starts from an empty router with sane default middleware:
request tracing, a 60s timeout, and a 25 MiB request body cap
(override with .max_body_bytes if a route needs to accept larger
uploads, e.g. crate tarballs).
Sourcepub fn max_body_bytes(self, bytes: usize) -> Self
pub fn max_body_bytes(self, bytes: usize) -> Self
Raises the request body size cap. Call this before merging in routes that need to accept large uploads.
Sourcepub fn merge(self, routes: Router<S>) -> Self
pub fn merge(self, routes: Router<S>) -> Self
Merges routes (from .route(...) calls or crate::mvc::resource)
into the app.
Sourcepub fn with_state(self, state: S) -> Router
pub fn with_state(self, state: S) -> Router
Attaches the shared application state, finishing the router.
Trait Implementations§
Auto Trait Implementations§
impl<S> !RefUnwindSafe for App<S>
impl<S> !UnwindSafe for App<S>
impl<S> Freeze for App<S>
impl<S> Send for App<S>
impl<S> Sync for App<S>
impl<S> Unpin for App<S>
impl<S> UnsafeUnpin for App<S>where
Router<S>: UnsafeUnpin,
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more