refactoring main
This commit is contained in:
parent
772bda8e93
commit
d866fa37a6
1 changed files with 15 additions and 11 deletions
26
src/main.rs
26
src/main.rs
|
@ -85,17 +85,7 @@ async fn main() -> io::Result<()> {
|
|||
.layer(TraceLayer::new_for_http())
|
||||
.layer(middleware::from_fn(log_source));
|
||||
|
||||
// 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);
|
||||
serve(app).await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -321,3 +311,17 @@ async fn download(
|
|||
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue