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: Default,
Available on crate feature auth
only.
pub fn basic(username: &str, password: &str) -> Selfwhere
ResBody: 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: Default,
pub fn accept(value: &str) -> Selfwhere
ResBody: 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 http_body_util::Full;
use bytes::Bytes;
use tower_http::validate_request::{AcceptHeader, ValidateRequestHeaderLayer};
let layer = ValidateRequestHeaderLayer::<AcceptHeader<Full<Bytes>>>::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