2021-05-31 16:28:26 +02:00
|
|
|
use http::Request;
|
|
|
|
use hyper::Server;
|
|
|
|
use std::net::SocketAddr;
|
|
|
|
use tower::make::Shared;
|
2021-05-31 20:42:57 +02:00
|
|
|
use tower_web::body::Body;
|
2021-05-31 16:28:26 +02:00
|
|
|
|
|
|
|
#[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();
|
|
|
|
}
|
|
|
|
|
2021-05-31 20:42:57 +02:00
|
|
|
async fn handler(_req: Request<Body>) -> &'static str {
|
|
|
|
"Hello, World!"
|
2021-05-31 16:28:26 +02:00
|
|
|
}
|