pub async fn run(self, req: Request, env: Env) -> Result<Response> {
        let (handlers, data, or_else_any_method_handler) = self.split();

        if let Some(handlers) = handlers.get(&req.method()) {
            if let Ok(Match { value, params }) = handlers.at(&req.path()) {
                let route_info = RouteContext {
                    data,
                    env,
                    params: params.into(),
                };
                return match value {
                    Handler::Sync(func) => (func)(req, route_info),
                    Handler::Async(func) => (func)(req, route_info).await,
                };
            }
        }

        for method in Method::all() {
            if method == Method::Head || method == Method::Options || method == Method::Trace {
                continue;
            }
            if let Some(handlers) = handlers.get(&method) {
                if let Ok(Match { .. }) = handlers.at(&req.path()) {
                    return Response::error("Method Not Allowed", 405);
                }
            }
        }

        if let Ok(Match { value, params }) = or_else_any_method_handler.at(&req.path()) {
            let route_info = RouteContext {
                data,
                env,
                params: params.into(),
            };
            return match value {
                Handler::Sync(func) => (func)(req, route_info),
                Handler::Async(func) => (func)(req, route_info).await,
            };
        }

        Response::error("Not Found", 404)
    }
/// Handle the request provided to the `Router` and return a `Future`.
Handle the request provided to the `Router` and return a `Future`.
Handle the request provided to the ` Router ` and return a ` Future ` .
pub async fn run(self, req: Request, env: Env) -> Result<Response> {
        let (handlers, data, or_else_any_method_handler) = self.split();
        if let Some(handlers) = handlers.get(&req.method()) {
            if let Ok(Match { value, params }) = handlers.at(&req.path()) {
                let route_info = RouteContext {
                    data,
                    env,
                    params: params.into(),
                };
                return match value {
                    Handler::Sync(func) => (func)(req, route_info),
                    Handler::Async(func) => (func)(req, route_info).await,
                };
            }
        }
        for method in Method::all() {
            if method == Method::Head || method == Method::Options || method == Method::Trace {
                continue;
            }
            if let Some(handlers) = handlers.get(&method) {
                if let Ok(Match { .. }) = handlers.at(&req.path()) {
                    return Response::error("Method Not Allowed", 405);
                }
            }
        }
        if let Ok(Match { value, params }) = or_else_any_method_handler.at(&req.path()) {
            let route_info = RouteContext {
                data,
                env,
                params: params.into(),
            };
            return match value {
                Handler::Sync(func) => (func)(req, route_info),
                Handler::Async(func) => (func)(req, route_info).await,
            };
        }
        Response::error("Not Found", 404)
    }
pub async fn run ( self , req : Request , env : Env ) -> Result < Response > { let ( handlers , data , or_else_any_method_handler ) = self . split ( ) ; if let Some ( handlers ) = handlers . get ( & req . method ( ) ) { if let Ok ( Match { value , params } ) = handlers . at ( & req . path ( ) ) { let route_info = RouteContext { data , env , params : params . into ( ) , } ; return match value { Handler :: Sync ( func ) => ( func ) ( req , route_info ) , Handler :: Async ( func ) => ( func ) ( req , route_info ) . await , } ; } } for method in Method :: all ( ) { if method == Method :: Head || method == Method :: Options || method == Method :: Trace { continue ; } if let Some ( handlers ) = handlers . get ( & method ) { if let Ok ( Match { .. } ) = handlers . at ( & req . path ( ) ) { return Response :: error ( " " , 405 ) ; } } } if let Ok ( Match { value , params } ) = or_else_any_method_handler . at ( & req . path ( ) ) { let route_info = RouteContext { data , env , params : params . into ( ) , } ; return match value { Handler :: Sync ( func ) => ( func ) ( req , route_info ) , Handler :: Async ( func ) => ( func ) ( req , route_info ) . await , } ; } Response :: error ( " " , 404 ) }
Handle the request provided to the `Router` and return a `Future`.
Handle the request provided to the ` Router ` and return a ` Future ` .
self
req
Request
env
Env
self
req
Request
env
Env