use http::Request; use hyper::Server; use std::net::SocketAddr; use tower::make::Shared; use tower_web::body::Body; #[tokio::main] async fn main() { // 100 routes should still compile in a reasonable amount of time // add a .boxed() every 10 routes to improve compile times let app = tower_web::app() .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .boxed() .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .boxed() .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .boxed() .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .boxed() .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .boxed() .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .boxed() .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .boxed() .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .boxed() .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .boxed() .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .at("/") .get(handler) .boxed() .into_service(); let addr = SocketAddr::from(([127, 0, 0, 1], 3000)); tracing::debug!("listening on {}", addr); let server = Server::bind(&addr).serve(Shared::new(app)); server.await.unwrap(); } async fn handler(_req: Request) -> &'static str { "Hello, World!" }