forked from Zynh0722/nyazoom
refactoring main
parent
772bda8e93
commit
d866fa37a6
26
src/main.rs
26
src/main.rs
|
@ -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);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue