rama_http/layer/validate_request/
validate.rs

1use crate::{Request, Response};
2use rama_core::Context;
3
4/// Trait for validating requests.
5pub trait ValidateRequest<S, B>: Send + Sync + 'static {
6    /// The body type used for responses to unvalidated requests.
7    type ResponseBody;
8
9    /// Validate the request.
10    ///
11    /// If `Ok(())` is returned then the request is allowed through, otherwise not.
12    fn validate(
13        &self,
14        ctx: Context<S>,
15        request: Request<B>,
16    ) -> impl Future<Output = Result<(Context<S>, Request<B>), Response<Self::ResponseBody>>> + Send + '_;
17}