mirror of
https://github.com/tokio-rs/axum.git
synced 2024-12-29 15:49:16 +01:00
232 lines
4.6 KiB
Rust
232 lines
4.6 KiB
Rust
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<Body>) -> &'static str {
|
|
"Hello, World!"
|
|
}
|