pub struct ValidateJsonLayer<T> { /* private fields */ }Expand description
A tower_layer::Layer that validates JSON request bodies with vld.
The type parameter T is the validated struct (must implement
VldParse + Clone + Send + Sync + 'static).
§Behaviour
- Reads the full request body.
- Parses as JSON and validates via
T::vld_parse_value(). - Valid — inserts
Tinto request extensions, re-attaches the body bytes, and calls the inner service. - Invalid — returns
422 Unprocessable Entitywith a JSON body containing the validation errors. The inner service is not called.
Requests without Content-Type: application/json (or missing content
type) are passed through without validation.
Implementations§
Source§impl<T> ValidateJsonLayer<T>
impl<T> ValidateJsonLayer<T>
Trait Implementations§
Source§impl<T: Clone> Clone for ValidateJsonLayer<T>
impl<T: Clone> Clone for ValidateJsonLayer<T>
Source§fn clone(&self) -> ValidateJsonLayer<T>
fn clone(&self) -> ValidateJsonLayer<T>
Returns a duplicate 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 moreSource§impl<T> Default for ValidateJsonLayer<T>
impl<T> Default for ValidateJsonLayer<T>
Auto Trait Implementations§
impl<T> Freeze for ValidateJsonLayer<T>
impl<T> RefUnwindSafe for ValidateJsonLayer<T>
impl<T> Send for ValidateJsonLayer<T>
impl<T> Sync for ValidateJsonLayer<T>
impl<T> Unpin for ValidateJsonLayer<T>
impl<T> UnsafeUnpin for ValidateJsonLayer<T>
impl<T> UnwindSafe for ValidateJsonLayer<T>
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