Struct axum::extract::TypedHeader
source · [−]pub struct TypedHeader<T>(pub T);
This is supported on crate feature
headers
only.Expand description
Extractor that extracts a typed header value from headers
.
In general, it’s recommended to extract only the needed headers via TypedHeader
rather than
removing all headers with the HeaderMap
extractor.
Example
use axum::{
extract::TypedHeader,
headers::UserAgent,
routing::get,
Router,
};
async fn users_teams_show(
TypedHeader(user_agent): TypedHeader<UserAgent>,
) {
// ...
}
let app = Router::new().route("/users/:user_id/team/:team_id", get(users_teams_show));
Tuple Fields
0: T
Trait Implementations
type Rejection = TypedHeaderRejection
type Rejection = TypedHeaderRejection
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> RefUnwindSafe for TypedHeader<T> where
T: RefUnwindSafe,
impl<T> Send for TypedHeader<T> where
T: Send,
impl<T> Sync for TypedHeader<T> where
T: Sync,
impl<T> Unpin for TypedHeader<T> where
T: Unpin,
impl<T> UnwindSafe for TypedHeader<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Create a new Policy
that returns Action::Follow
only if self
and other
return
Action::Follow
. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more