Trait saphir::handler::Handler

source ·
pub trait Handler<T> {
    type Responder: Responder;
    type Future: Future<Output = Self::Responder>;

    // Required method
    fn handle(&self, req: Request<T>) -> Self::Future;
}
Expand description

Define a Handler of a potential http request

Implementing this trait on any type will allow the router to route request towards it. Implemented by default on Controllers and on any async fn(Request<Body>) -> impl Responder

Required Associated Types§

source

type Responder: Responder

Responder returned by the handler

source

type Future: Future<Output = Self::Responder>

Specific future returning the responder

Required Methods§

source

fn handle(&self, req: Request<T>) -> Self::Future

Handle the http request, returning a future of a responder

Implementors§

source§

impl<T, Fun, Fut, R> Handler<T> for Funwhere Fun: Fn(Request<T>) -> Fut, Fut: 'static + Future<Output = R> + Send, R: Responder,

§

type Future = Box<dyn Future<Output = <Fun as Handler<T>>::Responder> + Unpin + Send + 'static, Global>

§

type Responder = R