use mimeograph_router::*; type Result = std::result::Result>; #[get("/")] pub fn home(_request: http::Request<()>) -> Result> { http::Response::builder() .body(String::from("home")) .map_err(Into::into) } #[get("/foo/bar/baz")] pub fn foo_bar_baz(_request: http::Request<()>) -> Result> { http::Response::builder() .body(String::from("hello world")) .map_err(Into::into) } #[get("/bar/baz/:qux")] pub fn bar_baz_qux( _request: http::Request<()>, _qux: &str, ) -> Result> { http::Response::builder() .body(String::default()) .map_err(Into::into) } #[tokio::main] async fn main() { let request = http::Request::get("http://mimeograph.roosterbockets.com/foo/bar/baz") .body(()) .unwrap(); let router = router![home, foo_bar_baz, bar_baz_qux]; let _response: http::Response = match router(request) { // Matched a route Some(Ok(resp)) => resp, // There was an error Some(Err(_err)) => { // convert err into an http::Response; todo!() } // No routes matched None => todo!(), }; }