pub struct Authorization<S: Scheme>(/* private fields */);
Expand description
Authorization
header, defined in RFC 7235
The “Authorization” header field allows a user agent to authenticate itself with an origin server—usually, but not necessarily, after receiving a 401 (Unauthorized) response. Its value consists of credentials containing the authentication information of the user agent for the realm of the resource being requested.
Authorization
is generic over an authentication scheme.
§Examples
fn handler(req: HttpRequest) -> Result<String> {
let auth = Authorization::<Basic>::parse(&req)?;
Ok(format!("Hello, {}!", auth.as_ref().user_id()))
}
Implementations§
source§impl<S: Scheme> Authorization<S>
impl<S: Scheme> Authorization<S>
sourcepub fn into_scheme(self) -> S
pub fn into_scheme(self) -> S
Consumes Authorization
header and returns inner Scheme
implementation.
Trait Implementations§
source§impl<S: Scheme> AsMut<S> for Authorization<S>
impl<S: Scheme> AsMut<S> for Authorization<S>
source§impl<S: Scheme> AsRef<S> for Authorization<S>
impl<S: Scheme> AsRef<S> for Authorization<S>
source§impl<S: Clone + Scheme> Clone for Authorization<S>
impl<S: Clone + Scheme> Clone for Authorization<S>
source§fn clone(&self) -> Authorization<S>
fn clone(&self) -> Authorization<S>
Returns a copy 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<S: Default + Scheme> Default for Authorization<S>
impl<S: Default + Scheme> Default for Authorization<S>
source§fn default() -> Authorization<S>
fn default() -> Authorization<S>
Returns the “default value” for a type. Read more
source§impl<S: Scheme> Display for Authorization<S>
impl<S: Scheme> Display for Authorization<S>
source§impl<S: Scheme> From<S> for Authorization<S>
impl<S: Scheme> From<S> for Authorization<S>
source§fn from(scheme: S) -> Authorization<S>
fn from(scheme: S) -> Authorization<S>
Converts to this type from the input type.
source§impl<S: Scheme> Header for Authorization<S>
impl<S: Scheme> Header for Authorization<S>
source§fn name() -> HeaderName
fn name() -> HeaderName
Returns the name of the header field.
source§fn parse<T: HttpMessage>(msg: &T) -> Result<Self, ParseError>
fn parse<T: HttpMessage>(msg: &T) -> Result<Self, ParseError>
Parse the header from a HTTP message.
source§impl<S: Ord + Scheme> Ord for Authorization<S>
impl<S: Ord + Scheme> Ord for Authorization<S>
source§fn cmp(&self, other: &Authorization<S>) -> Ordering
fn cmp(&self, other: &Authorization<S>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl<S: PartialOrd + Scheme> PartialOrd for Authorization<S>
impl<S: PartialOrd + Scheme> PartialOrd for Authorization<S>
source§impl<S: Scheme> TryIntoHeaderValue for Authorization<S>
impl<S: Scheme> TryIntoHeaderValue for Authorization<S>
source§type Error = <S as TryIntoHeaderValue>::Error
type Error = <S as TryIntoHeaderValue>::Error
The type returned in the event of a conversion error.
source§fn try_into_value(self) -> Result<HeaderValue, Self::Error>
fn try_into_value(self) -> Result<HeaderValue, Self::Error>
Try to convert value to a HeaderValue.
impl<S: Eq + Scheme> Eq for Authorization<S>
impl<S: Scheme> StructuralPartialEq for Authorization<S>
Auto Trait Implementations§
impl<S> Freeze for Authorization<S>where
S: Freeze,
impl<S> RefUnwindSafe for Authorization<S>where
S: RefUnwindSafe,
impl<S> Send for Authorization<S>
impl<S> Sync for Authorization<S>
impl<S> Unpin for Authorization<S>where
S: Unpin,
impl<S> UnwindSafe for Authorization<S>where
S: 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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.