pub fn route_async<F, U>(mut self, path: &str, cb: F) -> Self
    where
        F: Fn(Request<hyper::Body>) -> U + Send + Sync + 'static,
        U: TryFuture<Ok = Response<Bytes>> + Send + Sync + 'static,
        U::Error: Into<BoxError> + Send + 'static,
    {
        let func = move |req| {
            Box::pin(cb(req).map_err(Into::into))
                as Pin<
                    Box<
                        dyn Future<Output = Result<Response<Bytes>, BoxError>>
                            + Send
                            + Sync
                            + 'static,
                    >,
                >
        };
        self.routes.insert(path.into(), Route(Box::new(func)));
        self
    }
/// Call a closure when the request matches, returning a Future of
/// a response to send back.
Call a closure when the request matches, returning a Future of
a response to send back.
Call a closure when the request matches returning a Future of a response to send back .
pub fn route_async<F, U>(mut self, path: &str, cb: F) -> Self
    where
        F: Fn(Request<hyper::Body>) -> U + Send + Sync + 'static,
        U: TryFuture<Ok = Response<Bytes>> + Send + Sync + 'static,
        U::Error: Into<BoxError> + Send + 'static,
    {
        let func = move |req| {
            Box::pin(cb(req).map_err(Into::into))
                as Pin<
                    Box<
                        dyn Future<Output = Result<Response<Bytes>, BoxError>>
                            + Send
                            + Sync
                            + 'static,
                    >,
                >
        };
        self.routes.insert(path.into(), Route(Box::new(func)));
        self
    }
pub fn route_async < F , U > ( mut self , path : & str , cb : F ) -> Self where F : Fn ( Request < hyper :: Body > ) -> U + Send + Sync + ' static , U : TryFuture < Ok = Response < Bytes > > + Send + Sync + ' static , U :: Error : Into < BoxError > + Send + ' static , { let func = move | req | { Box :: pin ( cb ( req ) . map_err ( Into :: into ) ) as Pin < Box < dyn Future < Output = Result < Response < Bytes > , BoxError > > + Send + Sync + ' static , > , > } ; self . routes . insert ( path . into ( ) , Route ( Box :: new ( func ) ) ) ; self }
Call a closure when the request matches, returning a Future of
a response to send back.
Call a closure when the request matches returning a Future of a response to send back .
mut self
path
&str
cb
F
mut self
path
&str
cb
F