Add serve function and remove Server re-export (#1868)

This commit is contained in:
David Pedersen
2023-04-21 17:45:31 +02:00
parent 6703f8634c
commit c97967252d
86 changed files with 641 additions and 564 deletions
+3 -3
View File
@@ -103,9 +103,9 @@ fn calling_serve_dir_from_a_handler() -> Router {
async fn serve(app: Router, port: u16) {
let addr = SocketAddr::from(([127, 0, 0, 1], port));
tracing::debug!("listening on {}", addr);
axum::Server::bind(&addr)
.serve(app.layer(TraceLayer::new_for_http()).into_make_service())
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
tracing::debug!("listening on {}", listener.local_addr().unwrap());
axum::serve(listener, app.layer(TraceLayer::new_for_http()))
.await
.unwrap();
}