pub async fn respond<R>(&self, req: impl Into<http_types::Request>) -> http_types::Result<R>
    where
        R: From<http_types::Response>,
    {
        let req = req.into();
        let Self {
            router,
            state,
            middleware,
        } = self.clone();

        let method = req.method().to_owned();
        let Selection { endpoint, params } = router.route(&req.url().path(), method);
        let route_params = vec![params];
        let req = Request::new(state, req, route_params);

        let next = Next {
            endpoint,
            next_middleware: &middleware,
        };

        let res = next.run(req).await;
        let res: http_types::Response = res.into();
        Ok(res.into())
    }
/// Respond to a `Request` with a `Response`.
///
/// This method is useful for testing endpoints directly,
/// or for creating servers over custom transports.
///
/// # Examples
///
/// ```no_run
/// # #[async_std::main]
/// # async fn main() -> http_types::Result<()> {
/// #
/// use tide::http::{Url, Method, Request, Response};
///
/// let mut app = tide::new();
/// app.at("/").get(|_| async { Ok("hello world") });
///
/// let req = Request::new(Method::Get, Url::parse("https://example.com")?);
/// let res: Response = app.respond(req).await?;
///
/// assert_eq!(res.status(), 200);
/// #
/// # Ok(()) }
/// ```
Respond to a `Request` with a `Response`.
This method is useful for testing endpoints directly,
or for creating servers over custom transports.
Respond to a ` Request ` with a ` Response ` . This method is useful for testing endpoints directly or for creating servers over custom transports .
pub async fn respond<R>(&self, req: impl Into<http_types::Request>) -> http_types::Result<R>
    where
        R: From<http_types::Response>,
    {
        let req = req.into();
        let Self {
            router,
            state,
            middleware,
        } = self.clone();
        let method = req.method().to_owned();
        let Selection { endpoint, params } = router.route(&req.url().path(), method);
        let route_params = vec![params];
        let req = Request::new(state, req, route_params);
        let next = Next {
            endpoint,
            next_middleware: &middleware,
        };
        let res = next.run(req).await;
        let res: http_types::Response = res.into();
        Ok(res.into())
    }
pub async fn respond < R > ( & self , req : impl Into < http_types :: Request > ) -> http_types :: Result < R > where R : From < http_types :: Response > , { let req = req . into ( ) ; let Self { router , state , middleware , } = self . clone ( ) ; let method = req . method ( ) . to_owned ( ) ; let Selection { endpoint , params } = router . route ( & req . url ( ) . path ( ) , method ) ; let route_params = vec ! [ params ] ; let req = Request :: new ( state , req , route_params ) ; let next = Next { endpoint , next_middleware : & middleware , } ; let res = next . run ( req ) . await ; let res : http_types :: Response = res . into ( ) ; Ok ( res . into ( ) ) }
Respond to a `Request` with a `Response`.
Respond to a ` Request ` with a ` Response ` .
&self
req
impl Into<http_types::Request>
&self
req
impl Into<http_types::Request>
examples
None
#[async_std::main]
None
async fn main() -> http_types::result<()> {
use tide::http::{Url, Method, Request, Response}.






use tide :: http :: { Url Method Request Response } .
ok(()) }
None