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",
|
"actix-web",
|
||||||
"clap",
|
"clap",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
|
"log",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -6,4 +6,5 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
clap = {version = "4.5.9", features = ["derive", "env"]}
|
clap = {version = "4.5.9", features = ["derive", "env"]}
|
||||||
actix-web = "4"
|
actix-web = "4"
|
||||||
env_logger = "0.11.5"
|
env_logger = "0.11.5"
|
||||||
|
log = "0.4.22"
|
@ -7,9 +7,9 @@ use env_logger::Env;
|
|||||||
#[derive(clap::Parser, Debug)]
|
#[derive(clap::Parser, Debug)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Name of the person to greet
|
/// Listen address
|
||||||
#[arg(env, short, long, default_value = "0.0.0.0:8000")]
|
#[arg(env, short, long, default_value = "0.0.0.0:8000")]
|
||||||
listen_url: String,
|
listen_addr: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
@ -32,6 +32,8 @@ async fn main() -> std::io::Result<()> {
|
|||||||
|
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
|
log::info!("Starting to listen on {}", args.listen_addr);
|
||||||
|
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
App::new()
|
App::new()
|
||||||
.wrap(Logger::default())
|
.wrap(Logger::default())
|
||||||
@ -39,7 +41,7 @@ async fn main() -> std::io::Result<()> {
|
|||||||
.service(echo)
|
.service(echo)
|
||||||
.route("/hey", web::get().to(manual_hello))
|
.route("/hey", web::get().to(manual_hello))
|
||||||
})
|
})
|
||||||
.bind(args.listen_url)?
|
.bind(args.listen_addr)?
|
||||||
.run()
|
.run()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user