Skip to main content

HttpService

Trait HttpService 

Source
pub trait HttpService: Service {
    type RequestBody: BufStream;
    type ResponseBody: BufStream;
    type Error;
    type Future: Future<Item = Response<Self::ResponseBody>, Error = Self::Error>;

    // Required methods
    fn poll_http_ready(&mut self) -> Poll<(), Self::Error>;
    fn call_http(&mut self, request: Request<Self::RequestBody>) -> Self::Future;

    // Provided method
    fn lift(self) -> LiftService<Self>
       where Self: Sized { ... }
}
Expand description

An HTTP service

This is not intended to be implemented directly. Instead, it is a trait alias of sorts, aliasing tower_service::Service trait with http::Request and http::Response types.

Required Associated Types§

Source

type RequestBody: BufStream

Request payload.

Source

type ResponseBody: BufStream

The HTTP response body type.

Source

type Error

The service error type

Source

type Future: Future<Item = Response<Self::ResponseBody>, Error = Self::Error>

The future response value.

Required Methods§

Source

fn poll_http_ready(&mut self) -> Poll<(), Self::Error>

Returns Ready when the service is able to process requests.

Source

fn call_http(&mut self, request: Request<Self::RequestBody>) -> Self::Future

Process the request and return the response asynchronously.

Provided Methods§

Source

fn lift(self) -> LiftService<Self>
where Self: Sized,

Wraps self with LiftService. This provides an implementation of Service for Self.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<T, B1, B2> HttpService for T
where T: Service<Request = Request<B1>, Response = Response<B2>>, B1: BufStream, B2: BufStream,