feat: show url on startup

This commit is contained in:
itsscb 2025-06-23 20:37:59 +02:00
parent aaaed7ce62
commit f3d8c27fb8
2 changed files with 6 additions and 4 deletions

View File

@ -14,7 +14,7 @@ use stammbaum::{Stammbaum, StammbaumFull};
use std::io::BufReader;
use tokio::runtime::Runtime;
use tower_http::trace::TraceLayer;
use tracing::{error, instrument, warn};
use tracing::{error, info, instrument, warn};
mod person;
mod stammbaum;
@ -74,7 +74,7 @@ async fn list_stammbaum(
}
}
pub fn run() -> Result<(), String> {
pub fn run<T: AsRef<str>>(address: T) -> Result<(), String> {
let rt = Runtime::new().map_err(|e| e.to_string())?;
rt.block_on(async {
#[allow(clippy::expect_used)]
@ -89,10 +89,12 @@ pub fn run() -> Result<(), String> {
.layer(TraceLayer::new_for_http())
.with_state(stammbaum);
let addr = tokio::net::TcpListener::bind("0.0.0.0:3000")
let addr = tokio::net::TcpListener::bind(address.as_ref())
.await
.expect("faild to bind port");
info!(address = address.as_ref(), "listening_on");
serve(addr, app).await.map_err(|e| e.to_string())
})
.map_err(|e| e.to_string())?;

View File

@ -9,5 +9,5 @@ fn main() {
.unwrap(),
)
.init();
run().unwrap();
run("0.0.0.0:3000").unwrap();
}