1
0
Fork 0

refactoring main

Zynh Ludwig 2024-08-28 19:10:05 -07:00
parent 772bda8e93
commit d866fa37a6
1 changed files with 15 additions and 11 deletions

View File

@ -85,17 +85,7 @@ async fn main() -> io::Result<()> {
.layer(TraceLayer::new_for_http()) .layer(TraceLayer::new_for_http())
.layer(middleware::from_fn(log_source)); .layer(middleware::from_fn(log_source));
// Server creation serve(app).await;
let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(
listener,
app.into_make_service_with_connect_info::<SocketAddr>(),
)
.await
.unwrap();
tracing::debug!("listening on http://{}/", addr);
Ok(()) Ok(())
} }
@ -321,3 +311,17 @@ async fn download(
Ok(Redirect::to("/404.html").into_response()) Ok(Redirect::to("/404.html").into_response())
} }
async fn serve(app: Router) {
// // Server creation
let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
axum::serve(
listener,
app.into_make_service_with_connect_info::<SocketAddr>(),
)
.await
.unwrap();
tracing::debug!("listening on http://{}/", addr);
}