http_private: add keep_alive options

This commit is contained in:
Joakim Frostegård 2022-04-03 19:30:43 +02:00
parent 26cd34f10a
commit bf4b32748b
2 changed files with 4 additions and 2 deletions

View file

@ -57,6 +57,7 @@ pub struct NetworkConfig {
pub tls_certificate_path: PathBuf,
/// Path to TLS private key (DER-encoded ASN.1 in PKCS#8 or PKCS#1 format)
pub tls_private_key_path: PathBuf,
pub keep_alive: bool,
}
impl Default for NetworkConfig {
@ -65,6 +66,7 @@ impl Default for NetworkConfig {
address: SocketAddr::from(([0, 0, 0, 0], 3000)),
tls_certificate_path: "".into(),
tls_private_key_path: "".into(),
keep_alive: true,
}
}
}

View file

@ -59,12 +59,12 @@ async fn run_app(
let app = Router::new()
.route("/announce/:user_token/", get(routes::announce))
.layer(Extension(Arc::new(config)))
.layer(Extension(Arc::new(config.clone())))
.layer(Extension(pool))
.layer(Extension(Arc::new(request_sender)));
axum::Server::builder(tls_acceptor)
.http1_keepalive(false)
.http1_keepalive(config.network.keep_alive)
.serve(app.into_make_service_with_connect_info::<SocketAddr>())
.await?;