Trait HttpMiddleware

Source
pub trait HttpMiddleware<S>: Sealed<S> {
    type RequestBody: BufStream;
    type ResponseBody: BufStream;
    type Error;
    type Service: HttpService<RequestBody = Self::RequestBody, ResponseBody = Self::ResponseBody, Error = Self::Error>;

    // Required method
    fn wrap_http(&self, inner: S) -> Self::Service;
}
Expand description

HTTP middleware trait

A trait “alias” for Middleware where the yielded service is an HttpService.

Using HttpMiddleware in where bounds is easier than trying to use Middleware directly.

Required Associated Types§

Source

type RequestBody: BufStream

The HTTP request body handled by the wrapped service.

Source

type ResponseBody: BufStream

The HTTP response body returned by the wrapped service.

Source

type Error

The wrapped service’s error type.

Source

type Service: HttpService<RequestBody = Self::RequestBody, ResponseBody = Self::ResponseBody, Error = Self::Error>

The wrapped service.

Required Methods§

Source

fn wrap_http(&self, inner: S) -> Self::Service

Wrap the given service with the middleware, returning a new servicee that has been decorated with the middleware.

Implementors§

Source§

impl<T, S, B1, B2> HttpMiddleware<S> for T
where T: Middleware<S, Request = Request<B1>, Response = Response<B2>>, B1: BufStream, B2: BufStream,