1use novax_tokio::tokio as tokio;
2
3use axum::Router;
4use std::error::Error;
5use tokio::net::TcpListener;
6use core::future::Future;
7
8pub async fn http_svc<F>(app: Router, addr: String, f: F) -> Result<(), Box::<dyn Error> >
9 where F: Future<Output = ()> + Send + 'static
10{
11 let addr = addr.parse::<std::net::SocketAddr>()?;
12 let listener = TcpListener::bind(&addr).await?;
13 let rslt = match axum::serve(listener, app.into_make_service())
14 .with_graceful_shutdown(f)
15 .await
16 {
17 Ok(rslt) => Ok( rslt ),
18 Err(e) => Err(e.into())
19 };
20 rslt
21}
22
23pub use axum;