pub async fn dispatch(&self, req: Request<Body>) -> Result<Response<Body>, Infallible> {
        let _uri = req.uri().clone();
        let _method = req.method().clone();

        #[cfg(all(feature = "logging", not(feature = "trace")))]
        log::info!("{} request to {}", _method, _uri);

        #[cfg(feature = "trace")]
        tracing::info!("{} request to {}", _method, _uri);

        match self.router.dispatch(req, self.clone()).await {
            Ok(resp) => {
                let _status = resp.status().clone();

                #[cfg(all(feature = "logging", not(feature = "trace")))]
                log::info!(
                    "{} request to {}: responding with status {}",
                    _method,
                    _uri,
                    _status,
                );

                #[cfg(feature = "trace")]
                tracing::info!(
                    "{} request to {}: responding with status {}",
                    _method,
                    _uri,
                    _status,
                );

                Ok(resp)
            }
            Err(e) => {
                #[cfg(all(feature = "logging", not(feature = "trace")))]
                log::error!(
                    "{} request to {}: responding with error {:?}",
                    _method,
                    _uri,
                    e,
                );

                #[cfg(feature = "trace")]
                tracing::error!(
                    "{} request to {}: responding with error {:?}",
                    _method,
                    _uri,
                    e,
                );
                match e.clone() {
                    Error::StatusCode(sc, msg) => Ok(Response::builder()
                        .status(sc)
                        .body(Body::from(msg))
                        .unwrap()),
                    Error::InternalServerError(e) => Ok(Response::builder()
                        .status(StatusCode::INTERNAL_SERVER_ERROR)
                        .body(Body::from(e.to_string()))
                        .unwrap()),
                }
            }
        }
    }
/// Dispatch a route based on the request. Returns a response based on the error status of the
/// handler chain following the normal chain of responsibility rules described elsewhere. Only
/// needed by server implementors.
Dispatch a route based on the request. Returns a response based on the error status of the
handler chain following the normal chain of responsibility rules described elsewhere. Only
needed by server implementors.
Dispatch a route based on the request . Returns a response based on the error status of the handler chain following the normal chain of responsibility rules described elsewhere . Only needed by server implementors .
pub async fn dispatch(&self, req: Request<Body>) -> Result<Response<Body>, Infallible> {
        let _uri = req.uri().clone();
        let _method = req.method().clone();
        #[cfg(all(feature = "logging", not(feature = "trace")))]
        log::info!("{} request to {}", _method, _uri);
        #[cfg(feature = "trace")]
        tracing::info!("{} request to {}", _method, _uri);
        match self.router.dispatch(req, self.clone()).await {
            Ok(resp) => {
                let _status = resp.status().clone();
                #[cfg(all(feature = "logging", not(feature = "trace")))]
                log::info!(
                    "{} request to {}: responding with status {}",
                    _method,
                    _uri,
                    _status,
                );
                #[cfg(feature = "trace")]
                tracing::info!(
                    "{} request to {}: responding with status {}",
                    _method,
                    _uri,
                    _status,
                );
                Ok(resp)
            }
            Err(e) => {
                #[cfg(all(feature = "logging", not(feature = "trace")))]
                log::error!(
                    "{} request to {}: responding with error {:?}",
                    _method,
                    _uri,
                    e,
                );
                #[cfg(feature = "trace")]
                tracing::error!(
                    "{} request to {}: responding with error {:?}",
                    _method,
                    _uri,
                    e,
                );
                match e.clone() {
                    Error::StatusCode(sc, msg) => Ok(Response::builder()
                        .status(sc)
                        .body(Body::from(msg))
                        .unwrap()),
                    Error::InternalServerError(e) => Ok(Response::builder()
                        .status(StatusCode::INTERNAL_SERVER_ERROR)
                        .body(Body::from(e.to_string()))
                        .unwrap()),
                }
            }
        }
    }
pub async fn dispatch ( & self , req : Request < Body > ) -> Result < Response < Body > , Infallible > { let _uri = req . uri ( ) . clone ( ) ; let _method = req . method ( ) . clone ( ) ; # [ cfg ( all ( feature " " not ( feature " " ) ) ) ] log :: info ! ( " " _method _uri ) ; # [ cfg ( feature " " ) ] tracing :: info ! ( " " _method _uri ) ; match self . router . dispatch ( req , self . clone ( ) ) . await { Ok ( resp ) => { let _status = resp . status ( ) . clone ( ) ; # [ cfg ( all ( feature " " not ( feature " " ) ) ) ] log :: info ! ( " " _method _uri _status ) ; # [ cfg ( feature " " ) ] tracing :: info ! ( " " _method _uri _status ) ; Ok ( resp ) } Err ( e ) => { # [ cfg ( all ( feature " " not ( feature " " ) ) ) ] log :: error ! ( " " _method _uri e ) ; # [ cfg ( feature " " ) ] tracing :: error ! ( " " _method _uri e ) ; match e . clone ( ) { Error :: StatusCode ( sc , msg ) => Ok ( Response :: builder ( ) . status ( sc ) . body ( Body :: from ( msg ) ) . unwrap ( ) ) , Error :: InternalServerError ( e ) => Ok ( Response :: builder ( ) . status ( StatusCode :: INTERNAL_SERVER_ERROR ) . body ( Body :: from ( e . to_string ( ) ) ) . unwrap ( ) ) , } } } }
Dispatch a route based on the request.
Dispatch a route based on the request .
&self
req
Request<Body>
&self
req
Request<Body>