pub struct MiddlewareSet { /* private fields */ }Expand description
A middleware collection. The middleware in this set is executed in the specified order at creation.
Implementations§
Source§impl MiddlewareSet
impl MiddlewareSet
Sourcepub fn new(handlers: Vec<MiddlewareHandler>) -> Self
pub fn new(handlers: Vec<MiddlewareHandler>) -> Self
Create new middleware set. This will include middleware that runs on every controller, if any is configured.
Sourcepub fn without_default(handlers: Vec<MiddlewareHandler>) -> Self
pub fn without_default(handlers: Vec<MiddlewareHandler>) -> Self
Create a middleware set without the default middleware that runs on every controller. Your controller will only run your middleware, and included features like request tracking will be disabled on your controller.
Sourcepub async fn handle_request(
&self,
request: Request,
) -> Result<(Outcome, usize), Error>
pub async fn handle_request( &self, request: Request, ) -> Result<(Outcome, usize), Error>
Handle an incoming request, by sending it through the middleware chain.
Sourcepub async fn handle_response(
&self,
request: &Request,
response: Response,
executed: usize,
) -> Result<Response, Error>
pub async fn handle_response( &self, request: &Request, response: Response, executed: usize, ) -> Result<Response, Error>
Handle the response received from a controller, by sending it back through the middleware chain in reverse order.
If a request was intercepted by a middleware in the chain, only the middleware that already ran will be executed.
Sourcepub fn handlers(&self) -> Vec<MiddlewareHandler>
pub fn handlers(&self) -> Vec<MiddlewareHandler>
Returns a clone of the middleware wrappers. They cannot be executed manually.
Trait Implementations§
Source§impl Clone for MiddlewareSet
impl Clone for MiddlewareSet
Source§fn clone(&self) -> MiddlewareSet
fn clone(&self) -> MiddlewareSet
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more