diff options
| author | Naz <ndpm13@ch-naseem.com> | 2025-10-12 11:00:08 +0100 |
|---|---|---|
| committer | Naz <ndpm13@ch-naseem.com> | 2025-10-12 11:00:08 +0100 |
| commit | 8a4544fc183e112564bdc6ac8511152c92ce7c56 (patch) | |
| tree | fe9102440b8c747f2f29902eecf35007b7c93936 /src/lib.rs | |
| parent | bbce03f95d82d5373f2b6a1c28b03eb25d7bb94c (diff) | |
✨feat: add tracingdev
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -3,6 +3,7 @@ mod config; mod errors; mod handlers; mod models; +mod trace; pub use errors::{Error, Result}; @@ -11,7 +12,7 @@ use std::net::{IpAddr, Ipv6Addr, SocketAddr}; use axum::{Router, routing::get}; use clap::Parser; use tokio::net::TcpListener; -use tower_http::services::ServeFile; +use tower_http::{services::ServeFile, trace::TraceLayer}; use args::{Cli, Command}; use config::Config; @@ -21,6 +22,7 @@ pub fn app(config: Config) -> Router { .nest_service("/static/style.css", ServeFile::new(&config.style_file)) .nest_service("/static/favicon.svg", ServeFile::new(&config.favicon_file)) .route("/", get(handlers::handler)) + .layer(TraceLayer::new_for_http()) .with_state(config) } @@ -31,8 +33,12 @@ pub async fn run() -> Result<()> { Command::Serv(args) => { let config = config::Config::new(args)?; + trace::tracing_registry(); + let socket = SocketAddr::new(IpAddr::V6(Ipv6Addr::UNSPECIFIED), config.port); + let listener = TcpListener::bind(socket).await?; + tracing::info!("listening on {}", listener.local_addr()?); axum::serve(listener, app(config.clone())).await?; } |
