chore: fix http mode load

This commit is contained in:
Jesús Pérez 2023-08-14 20:39:59 +00:00
parent 5ee4a522d4
commit 3ed622da54

View File

@ -335,16 +335,22 @@ async fn main() {
);
}
let addr = get_socket_addr(&config.bind,config.port);
tracing::debug!("listening on {}", addr);
println!("listening on {}", addr);
tracing::debug!("listening on {} url: {}://{}", addr, config.protocol, config.hostport);
println!("listening on {} url: {}://{}", addr, config.protocol, config.hostport);
if config.protocol.as_str() == "http" {
// let app_with_middleware = middleware.layer(app);
// run https server
//let addr = SocketAddr::from(([127, 0, 0, 1], ports.http));
//tracing::debug!("listening on {}", addr);
// .into_make_service_with_connect_info::<SocketAddr>()
//.into_make_service_with_connect_info::<AppConnectInfo>()
if config.verbose > 0 {
web_router = web_router.layer(TraceLayer::new_for_http());
}
let listener = tokio::net::TcpListener::bind(addr).await.unwrap();
axum::serve(listener, web_router.layer(TraceLayer::new_for_http())
.into_make_service_with_connect_info::<SocketAddr>()
// web_router.into_make_service_with_connect_info::<SocketAddr>()
axum::serve(listener, web_router
.into_make_service_with_connect_info::<AppConnectInfo>()
)
.await
.unwrap();
@ -372,6 +378,9 @@ async fn main() {
//let app_with_middleware = middleware.layer(app);
// apply the layer around the whole `Router`middleware.layer(app);
// .serve(web_router.into_make_service())
if config.verbose > 0 {
web_router = web_router.layer(TraceLayer::new_for_http());
}
axum_server::bind_rustls(addr, tls_config)
.serve(
// web_router.layer(TraceLayer::new_for_http())