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

This commit is contained in:
David Pedersen
2023-03-23 20:25:36 +01:00
parent 2ae0cdf7cf
commit d153719bef
86 changed files with 641 additions and 564 deletions
+8 -4
View File
@@ -66,12 +66,16 @@ async fn main() {
);
// run it with hyper
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
tracing::debug!("listening on {}", addr);
axum::Server::bind(&addr)
.serve(app.into_make_service_with_connect_info::<SocketAddr>())
let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
.await
.unwrap();
tracing::debug!("listening on {}", listener.local_addr().unwrap());
axum::serve(
listener,
app.into_make_service_with_connect_info::<SocketAddr>(),
)
.await
.unwrap();
}
/// The handler for the HTTP request (this gets called when the HTTP GET lands at the start