[][src]Trait saphir::handler::Handler

pub trait Handler<T> {
    type Responder: Responder;
    type Future: Future<Output = Self::Responder>;
    fn handle(&self, req: Request<T>) -> Self::Future;
}

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

Associated Types

type Responder: Responder

Responder returned by the handler

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

Specific future returning the responder

Loading content...

Required methods

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

Handle the http request, returning a future of a responder

Loading content...

Implementors

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

type Future = Box<dyn Future<Output = Self::Responder> + Unpin + Send>

type Responder = R

Loading content...