pub struct NamedHeader<T, N> {
pub value: T,
/* private fields */
}Expand description
Named header extractor with explicit header name.
Use this when the header name doesn’t match a type name.
§Example
ⓘ
use fastapi_core::extract::NamedHeader;
async fn handler(
auth: NamedHeader<String, AuthorizationHeader>,
trace: NamedHeader<String, XRequestIdHeader>,
) -> impl IntoResponse {
// ...
}
struct AuthorizationHeader;
impl HeaderName for AuthorizationHeader {
const NAME: &'static str = "Authorization";
}Fields§
§value: TThe extracted header value.
Implementations§
Source§impl<T, N> NamedHeader<T, N>
impl<T, N> NamedHeader<T, N>
Sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Unwrap the inner value.
Trait Implementations§
Source§impl<T: Clone, N: Clone> Clone for NamedHeader<T, N>
impl<T: Clone, N: Clone> Clone for NamedHeader<T, N>
Source§fn clone(&self) -> NamedHeader<T, N>
fn clone(&self) -> NamedHeader<T, N>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T, N> Deref for NamedHeader<T, N>
impl<T, N> Deref for NamedHeader<T, N>
Source§impl<T, N> DerefMut for NamedHeader<T, N>
impl<T, N> DerefMut for NamedHeader<T, N>
Source§impl<T, N> FromRequest for NamedHeader<T, N>
impl<T, N> FromRequest for NamedHeader<T, N>
Source§type Error = HeaderExtractError
type Error = HeaderExtractError
Error type when extraction fails.
Source§async fn from_request(
_ctx: &RequestContext,
req: &mut Request,
) -> Result<Self, Self::Error>
async fn from_request( _ctx: &RequestContext, req: &mut Request, ) -> Result<Self, Self::Error>
Extract a value from the request. Read more
Auto Trait Implementations§
impl<T, N> Freeze for NamedHeader<T, N>where
T: Freeze,
impl<T, N> RefUnwindSafe for NamedHeader<T, N>where
T: RefUnwindSafe,
N: RefUnwindSafe,
impl<T, N> Send for NamedHeader<T, N>
impl<T, N> Sync for NamedHeader<T, N>
impl<T, N> Unpin for NamedHeader<T, N>
impl<T, N> UnwindSafe for NamedHeader<T, N>where
T: UnwindSafe,
N: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).