Trait axum::RequestExt
source · pub trait RequestExt<B>: Sealed<B> + Sized {
fn extract<E, M>(
self
) -> Pin<Box<dyn Future<Output = Result<E, <E as FromRequest<(), B, M>>::Rejection>> + Send + 'static, Global>>
where
E: 'static + FromRequest<(), B, M>,
M: 'static;
fn extract_with_state<E, S, M>(
self,
state: &S
) -> Pin<Box<dyn Future<Output = Result<E, <E as FromRequest<S, B, M>>::Rejection>> + Send, Global>>
where
E: 'static + FromRequest<S, B, M>,
S: Send + Sync;
fn extract_parts<E>(
&mut self
) -> Pin<Box<dyn Future<Output = Result<E, <E as FromRequestParts<()>>::Rejection>> + Send, Global>>
where
E: 'static + FromRequestParts<()>;
fn extract_parts_with_state<E, S, 'a>(
&'a mut self,
state: &'a S
) -> Pin<Box<dyn Future<Output = Result<E, <E as FromRequestParts<S>>::Rejection>> + Send + 'a, Global>>
where
E: 'static + FromRequestParts<S>,
S: Send + Sync;
fn with_limited_body(self) -> Result<Request<Limited<B>>, Request<B>>;
fn into_limited_body(self) -> Result<Limited<B>, B>;
}
Expand description
Extension trait that adds additional methods to Request
.
Required Methods
sourcefn extract<E, M>(
self
) -> Pin<Box<dyn Future<Output = Result<E, <E as FromRequest<(), B, M>>::Rejection>> + Send + 'static, Global>>where
E: 'static + FromRequest<(), B, M>,
M: 'static,
fn extract<E, M>(
self
) -> Pin<Box<dyn Future<Output = Result<E, <E as FromRequest<(), B, M>>::Rejection>> + Send + 'static, Global>>where
E: 'static + FromRequest<(), B, M>,
M: 'static,
Apply an extractor to this Request
.
This is just a convenience for E::from_request(req, &())
.
Note this consumes the request. Use RequestExt::extract_parts
if you’re not extracting
the body and don’t want to consume the request.
sourcefn extract_with_state<E, S, M>(
self,
state: &S
) -> Pin<Box<dyn Future<Output = Result<E, <E as FromRequest<S, B, M>>::Rejection>> + Send, Global>>where
E: 'static + FromRequest<S, B, M>,
S: Send + Sync,
fn extract_with_state<E, S, M>(
self,
state: &S
) -> Pin<Box<dyn Future<Output = Result<E, <E as FromRequest<S, B, M>>::Rejection>> + Send, Global>>where
E: 'static + FromRequest<S, B, M>,
S: Send + Sync,
Apply an extractor that requires some state to this Request
.
This is just a convenience for E::from_request(req, state)
.
Note this consumes the request. Use RequestExt::extract_parts_with_state
if you’re not
extracting the body and don’t want to consume the request.
sourcefn extract_parts<E>(
&mut self
) -> Pin<Box<dyn Future<Output = Result<E, <E as FromRequestParts<()>>::Rejection>> + Send, Global>>where
E: 'static + FromRequestParts<()>,
fn extract_parts<E>(
&mut self
) -> Pin<Box<dyn Future<Output = Result<E, <E as FromRequestParts<()>>::Rejection>> + Send, Global>>where
E: 'static + FromRequestParts<()>,
Apply a parts extractor to this Request
.
This is just a convenience for E::from_request_parts(parts, state)
.
sourcefn extract_parts_with_state<E, S, 'a>(
&'a mut self,
state: &'a S
) -> Pin<Box<dyn Future<Output = Result<E, <E as FromRequestParts<S>>::Rejection>> + Send + 'a, Global>>where
E: 'static + FromRequestParts<S>,
S: Send + Sync,
fn extract_parts_with_state<E, S, 'a>(
&'a mut self,
state: &'a S
) -> Pin<Box<dyn Future<Output = Result<E, <E as FromRequestParts<S>>::Rejection>> + Send + 'a, Global>>where
E: 'static + FromRequestParts<S>,
S: Send + Sync,
Apply a parts extractor that requires some state to this Request
.
This is just a convenience for E::from_request_parts(parts, state)
.
sourcefn with_limited_body(self) -> Result<Request<Limited<B>>, Request<B>>
fn with_limited_body(self) -> Result<Request<Limited<B>>, Request<B>>
Apply the default body limit.
If it is disabled, return the request as-is in Err
.
sourcefn into_limited_body(self) -> Result<Limited<B>, B>
fn into_limited_body(self) -> Result<Limited<B>, B>
Consumes the request, returning the body wrapped in Limited
if a
default limit is in place, or not wrapped if the
default limit is disabled.