Improve usability
This commit is contained in:
parent
663b6f285e
commit
05cde266a5
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -666,6 +666,7 @@ dependencies = [
|
||||
"actix-web",
|
||||
"clap",
|
||||
"env_logger",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -7,3 +7,4 @@ edition = "2021"
|
||||
clap = {version = "4.5.9", features = ["derive", "env"]}
|
||||
actix-web = "4"
|
||||
env_logger = "0.11.5"
|
||||
log = "0.4.22"
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user