use std::future::Future;
use std::sync::Arc;
use tako_rs_core::router::Router;
use super::run::run;
use super::run::run_with_rustls_config;
use crate::ServerConfig;
pub async fn serve_h3(router: Router, addr: &str, certs: Option<&str>, key: Option<&str>) {
if let Err(e) = run(
router,
addr,
certs,
key,
None::<std::future::Pending<()>>,
ServerConfig::default(),
)
.await
{
tracing::error!("HTTP/3 server error: {e}");
}
}
pub async fn serve_h3_with_shutdown(
router: Router,
addr: &str,
certs: Option<&str>,
key: Option<&str>,
signal: impl Future<Output = ()> + Send + 'static,
) {
if let Err(e) = run(
router,
addr,
certs,
key,
Some(signal),
ServerConfig::default(),
)
.await
{
tracing::error!("HTTP/3 server error: {e}");
}
}
pub async fn serve_h3_with_config(
router: Router,
addr: &str,
certs: Option<&str>,
key: Option<&str>,
config: ServerConfig,
) {
if let Err(e) = run(
router,
addr,
certs,
key,
None::<std::future::Pending<()>>,
config,
)
.await
{
tracing::error!("HTTP/3 server error: {e}");
}
}
pub async fn serve_h3_with_shutdown_and_config(
router: Router,
addr: &str,
certs: Option<&str>,
key: Option<&str>,
signal: impl Future<Output = ()> + Send + 'static,
config: ServerConfig,
) {
if let Err(e) = run(router, addr, certs, key, Some(signal), config).await {
tracing::error!("HTTP/3 server error: {e}");
}
}
pub async fn serve_h3_with_rustls_config(
router: Router,
addr: &str,
rustls_config: Arc<rustls::ServerConfig>,
config: ServerConfig,
) {
if let Err(e) = run_with_rustls_config(
router,
addr,
rustls_config,
None::<std::future::Pending<()>>,
config,
)
.await
{
tracing::error!("HTTP/3 server error: {e}");
}
}
pub async fn serve_h3_with_rustls_config_and_shutdown(
router: Router,
addr: &str,
rustls_config: Arc<rustls::ServerConfig>,
signal: impl Future<Output = ()> + Send + 'static,
config: ServerConfig,
) {
if let Err(e) = run_with_rustls_config(router, addr, rustls_config, Some(signal), config).await {
tracing::error!("HTTP/3 server error: {e}");
}
}