pub struct ValidateRequestHeaderLayer<T> { /* private fields */ }
Available on crate feature
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<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>
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 more