Trait cosworth::prelude::Middleware
source · pub trait Middleware<S>: 'static {
fn start(&self, req: &HttpRequest<S>) -> Result<Started, Error> { ... }
fn response(
&self,
req: &HttpRequest<S>,
resp: HttpResponse
) -> Result<Response, Error> { ... }
fn finish(&self, req: &HttpRequest<S>, resp: &HttpResponse) -> Finished { ... }
}
Expand description
Middleware definition
Provided Methods§
sourcefn start(&self, req: &HttpRequest<S>) -> Result<Started, Error>
fn start(&self, req: &HttpRequest<S>) -> Result<Started, Error>
Method is called when request is ready. It may return future, which should resolve before next middleware get called.
sourcefn response(
&self,
req: &HttpRequest<S>,
resp: HttpResponse
) -> Result<Response, Error>
fn response(
&self,
req: &HttpRequest<S>,
resp: HttpResponse
) -> Result<Response, Error>
Method is called when handler returns response, but before sending http message to peer.
sourcefn finish(&self, req: &HttpRequest<S>, resp: &HttpResponse) -> Finished
fn finish(&self, req: &HttpRequest<S>, resp: &HttpResponse) -> Finished
Method is called after body stream get sent to peer.