pub struct ValidateRequestHeaderLayer<T> { /* private fields */ }
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,
pub fn basic(username: &str, password: &str) -> Selfwhere
ResBody: Default,
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 moresource§impl<T: Debug> Debug for ValidateRequestHeaderLayer<T>
impl<T: Debug> Debug for ValidateRequestHeaderLayer<T>
source§impl<S, T> Layer<S> for ValidateRequestHeaderLayer<T>where
T: Clone,
impl<S, T> Layer<S> for ValidateRequestHeaderLayer<T>where
T: Clone,
Auto Trait Implementations§
impl<T> Freeze for ValidateRequestHeaderLayer<T>where
T: Freeze,
impl<T> RefUnwindSafe for ValidateRequestHeaderLayer<T>where
T: RefUnwindSafe,
impl<T> Send for ValidateRequestHeaderLayer<T>where
T: Send,
impl<T> Sync for ValidateRequestHeaderLayer<T>where
T: Sync,
impl<T> Unpin for ValidateRequestHeaderLayer<T>where
T: Unpin,
impl<T> UnwindSafe for ValidateRequestHeaderLayer<T>where
T: 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
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)
clone_to_uninit
)