Improve usability

This commit is contained in:
Pierre HUBERT 2024-08-19 15:24:52 +02:00
parent 663b6f285e
commit 05cde266a5
3 changed files with 8 additions and 4 deletions

1
Cargo.lock generated
View File

@ -666,6 +666,7 @@ dependencies = [
"actix-web",
"clap",
"env_logger",
"log",
]
[[package]]

View File

@ -6,4 +6,5 @@ edition = "2021"
[dependencies]
clap = {version = "4.5.9", features = ["derive", "env"]}
actix-web = "4"
env_logger = "0.11.5"
env_logger = "0.11.5"
log = "0.4.22"

View File

@ -7,9 +7,9 @@ use env_logger::Env;
#[derive(clap::Parser, Debug)]
#[command(version, about, long_about = None)]
struct Args {
/// Name of the person to greet
/// Listen address
#[arg(env, short, long, default_value = "0.0.0.0:8000")]
listen_url: String,
listen_addr: String,
}
#[get("/")]
@ -32,6 +32,8 @@ async fn main() -> std::io::Result<()> {
let args = Args::parse();
log::info!("Starting to listen on {}", args.listen_addr);
HttpServer::new(|| {
App::new()
.wrap(Logger::default())
@ -39,7 +41,7 @@ async fn main() -> std::io::Result<()> {
.service(echo)
.route("/hey", web::get().to(manual_hello))
})
.bind(args.listen_url)?
.bind(args.listen_addr)?
.run()
.await
}