Struct axum::extract::ContentLengthLimit [−][src]
pub struct ContentLengthLimit<T, const N: u64>(pub T);
Expand description
Extractor that will reject requests with a body larger than some size.
Example
use axum::prelude::*; async fn handler(body: extract::ContentLengthLimit<String, 1024>) { // ... } let app = route("/", post(handler));
This requires the request to have a Content-Length
header.
Tuple Fields
0: T
Trait Implementations
impl<T, B, const N: u64> FromRequest<B> for ContentLengthLimit<T, N> where
T: FromRequest<B>,
B: Send,
impl<T, B, const N: u64> FromRequest<B> for ContentLengthLimit<T, N> where
T: FromRequest<B>,
B: Send,
type Rejection = ContentLengthLimitRejection<T::Rejection>
type Rejection = ContentLengthLimitRejection<T::Rejection>
If the extractor fails it’ll use this “rejection” type. A rejection is a kind of error that can be converted into a response. Read more
fn from_request<'life0, 'async_trait>(
req: &'life0 mut RequestParts<B>
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Rejection>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
fn from_request<'life0, 'async_trait>(
req: &'life0 mut RequestParts<B>
) -> Pin<Box<dyn Future<Output = Result<Self, Self::Rejection>> + Send + 'async_trait>> where
'life0: 'async_trait,
Self: 'async_trait,
Perform the extraction.
Auto Trait Implementations
impl<T, const N: u64> RefUnwindSafe for ContentLengthLimit<T, N> where
T: RefUnwindSafe,
impl<T, const N: u64> Send for ContentLengthLimit<T, N> where
T: Send,
impl<T, const N: u64> Sync for ContentLengthLimit<T, N> where
T: Sync,
impl<T, const N: u64> Unpin for ContentLengthLimit<T, N> where
T: Unpin,
impl<T, const N: u64> UnwindSafe for ContentLengthLimit<T, N> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Create a new Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more
type Output = T
type Output = T
Should always be Self