[][src]Trait httprouter::Handler

pub trait Handler: Send + Sync {
    pub fn handle(
        &self,
        req: Request<Body>
    ) -> Pin<Box<dyn Future<Output = Result<Response<Body>>> + Send + Sync>>; }

Represents a HTTP handler function. This trait is implemented for asynchronous functions that take a Request and return a Result<Response<Body>, hyper::Error>

async fn hello(_: Request<Body>) -> Result<Response<Body>, hyper::Error> {
    Ok(Response::new(Body::empty()))
}

let handler: Box<dyn Handler> = Box::new(hello);

Required methods

pub fn handle(
    &self,
    req: Request<Body>
) -> Pin<Box<dyn Future<Output = Result<Response<Body>>> + Send + Sync>>
[src]

Loading content...

Implementors

impl<F, R> Handler for F where
    F: Fn(Request<Body>) -> R + Send + Sync,
    R: Future<Output = Result<Response<Body>, Error>> + Send + Sync + 'static, 
[src]

Loading content...