pub struct WwwAuthenticate { /* private fields */ }
Expand description
Define the authentication method that should be used to gain access to a resource.
§Specifications
§Implementation Notes
This implementation only encodes and parses a single authentication method, further authorization methods are ignored. It also always passes the utf-8 encoding flag.
§Examples
use http_types::Response;
use http_types::auth::{AuthenticationScheme, WwwAuthenticate};
let scheme = AuthenticationScheme::Basic;
let realm = "Access to the staging site";
let authz = WwwAuthenticate::new(scheme, realm.into());
let mut res = Response::new(200);
authz.apply(&mut res);
let authz = WwwAuthenticate::from_headers(res)?.unwrap();
assert_eq!(authz.scheme(), AuthenticationScheme::Basic);
assert_eq!(authz.realm(), realm);
Implementations§
Source§impl WwwAuthenticate
impl WwwAuthenticate
Sourcepub fn new(scheme: AuthenticationScheme, realm: String) -> Self
pub fn new(scheme: AuthenticationScheme, realm: String) -> Self
Create a new instance of WwwAuthenticate
.
Sourcepub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
pub fn from_headers(headers: impl AsRef<Headers>) -> Result<Option<Self>>
Create a new instance from headers.
Sourcepub fn name(&self) -> HeaderName
pub fn name(&self) -> HeaderName
Get the HeaderName
.
Sourcepub fn value(&self) -> HeaderValue
pub fn value(&self) -> HeaderValue
Get the HeaderValue
.
Sourcepub fn scheme(&self) -> AuthenticationScheme
pub fn scheme(&self) -> AuthenticationScheme
Get the authorization scheme.
Sourcepub fn set_scheme(&mut self, scheme: AuthenticationScheme)
pub fn set_scheme(&mut self, scheme: AuthenticationScheme)
Set the authorization scheme.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WwwAuthenticate
impl RefUnwindSafe for WwwAuthenticate
impl Send for WwwAuthenticate
impl Sync for WwwAuthenticate
impl Unpin for WwwAuthenticate
impl UnwindSafe for WwwAuthenticate
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