Init
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use axum::Router;
|
||||
use tokio::net::TcpListener;
|
||||
|
||||
use crate::config::AppConfig;
|
||||
use crate::routes;
|
||||
|
||||
pub async fn start(config: &AppConfig) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let addr = SocketAddr::new(
|
||||
std::net::IpAddr::V4(config.network.host),
|
||||
config.network.tcp_port,
|
||||
);
|
||||
|
||||
let app: Router = routes::router();
|
||||
|
||||
let listener = TcpListener::bind(addr).await?;
|
||||
tracing::info!(%addr, "HTTP server listening");
|
||||
|
||||
axum::serve(listener, app).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user