pub struct ValidateRequestHeaderLayer<T> { /* private fields */ }
validate-request
only.Expand description
Layer that applies ValidateRequestHeader
which validates all requests.
See the module docs for an example.
Implementations§
source§impl<ResBody> ValidateRequestHeaderLayer<Basic<ResBody>>
impl<ResBody> ValidateRequestHeaderLayer<Basic<ResBody>>
sourcepub fn basic(username: &str, password: &str) -> Selfwhere
ResBody: Body + Default,
Available on crate feature auth
only.
pub fn basic(username: &str, password: &str) -> Selfwhere ResBody: Body + Default,
auth
only.Authorize requests using a username and password pair.
The Authorization
header is required to be Basic {credentials}
where credentials
is
base64_encode("{username}:{password}")
.
Since the username and password is sent in clear text it is recommended to use HTTPS/TLS with this method. However use of HTTPS/TLS is not enforced by this middleware.
source§impl<ResBody> ValidateRequestHeaderLayer<Bearer<ResBody>>
impl<ResBody> ValidateRequestHeaderLayer<Bearer<ResBody>>
source§impl<ResBody> ValidateRequestHeaderLayer<AcceptHeader<ResBody>>
impl<ResBody> ValidateRequestHeaderLayer<AcceptHeader<ResBody>>
sourcepub fn accept(value: &str) -> Selfwhere
ResBody: Body + Default,
pub fn accept(value: &str) -> Selfwhere ResBody: Body + Default,
Validate requests have the required Accept header.
The Accept
header is required to be */*
, type/*
or type/subtype
,
as configured.
Panics
Panics if header_value
is not in the form: type/subtype
, such as application/json
See AcceptHeader::new
for when this method panics.
Example
use hyper::Body;
use tower_http::validate_request::{AcceptHeader, ValidateRequestHeaderLayer};
let layer = ValidateRequestHeaderLayer::<AcceptHeader<Body>>::accept("application/json");
source§impl<T> ValidateRequestHeaderLayer<T>
impl<T> ValidateRequestHeaderLayer<T>
sourcepub fn custom(validate: T) -> ValidateRequestHeaderLayer<T>
pub fn custom(validate: T) -> ValidateRequestHeaderLayer<T>
Validate requests using a custom method.
Trait Implementations§
source§impl<T: Clone> Clone for ValidateRequestHeaderLayer<T>
impl<T: Clone> Clone for ValidateRequestHeaderLayer<T>
source§fn clone(&self) -> ValidateRequestHeaderLayer<T>
fn clone(&self) -> ValidateRequestHeaderLayer<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more