feat: show url on startup
This commit is contained in:
parent
aaaed7ce62
commit
f3d8c27fb8
@ -14,7 +14,7 @@ use stammbaum::{Stammbaum, StammbaumFull};
|
|||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use tokio::runtime::Runtime;
|
use tokio::runtime::Runtime;
|
||||||
use tower_http::trace::TraceLayer;
|
use tower_http::trace::TraceLayer;
|
||||||
use tracing::{error, instrument, warn};
|
use tracing::{error, info, instrument, warn};
|
||||||
|
|
||||||
mod person;
|
mod person;
|
||||||
mod stammbaum;
|
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())?;
|
let rt = Runtime::new().map_err(|e| e.to_string())?;
|
||||||
rt.block_on(async {
|
rt.block_on(async {
|
||||||
#[allow(clippy::expect_used)]
|
#[allow(clippy::expect_used)]
|
||||||
@ -89,10 +89,12 @@ pub fn run() -> Result<(), String> {
|
|||||||
.layer(TraceLayer::new_for_http())
|
.layer(TraceLayer::new_for_http())
|
||||||
.with_state(stammbaum);
|
.with_state(stammbaum);
|
||||||
|
|
||||||
let addr = tokio::net::TcpListener::bind("0.0.0.0:3000")
|
let addr = tokio::net::TcpListener::bind(address.as_ref())
|
||||||
.await
|
.await
|
||||||
.expect("faild to bind port");
|
.expect("faild to bind port");
|
||||||
|
|
||||||
|
info!(address = address.as_ref(), "listening_on");
|
||||||
|
|
||||||
serve(addr, app).await.map_err(|e| e.to_string())
|
serve(addr, app).await.map_err(|e| e.to_string())
|
||||||
})
|
})
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
|
@ -9,5 +9,5 @@ fn main() {
|
|||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
.init();
|
.init();
|
||||||
run().unwrap();
|
run("0.0.0.0:3000").unwrap();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user