serenade-http 1.0.0

Framework-agnostic HTTP foundation types
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Middleware around [`crate::RequestHandler`].

use crate::{HttpError, Request, RequestHandler, Response};

/// Layer that may inspect or mutate the request, then call `next`.
pub trait Middleware: Send + Sync {
    /// Runs this layer.
    ///
    /// # Errors
    ///
    /// Returns [`HttpError`] instead of calling `next`, or when `next` fails.
    fn process(
        &self,
        request: &mut Request,
        next: &dyn RequestHandler,
    ) -> Result<Response, HttpError>;
}