0.3.3: Add port and address options (Nix packaging reasons)

Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
This commit is contained in:
Ivan Bushchik 2023-12-18 14:03:51 +03:00
parent 63a4b6b7fc
commit 9122166285
No known key found for this signature in database
GPG key ID: 2F16FBF3262E090C
2 changed files with 17 additions and 3 deletions

View file

@ -1,6 +1,6 @@
[package]
name = "urouter"
version = "0.3.1"
version = "0.3.3"
edition = "2021"
license = "MIT"
repository = "https://github.com/ivabus/urouter"

View file

@ -27,6 +27,7 @@ extern crate rocket;
use rocket::http::Status;
use std::cell::OnceCell;
use std::net::IpAddr;
use std::path::PathBuf;
use rocket::request::{FromRequest, Outcome};
@ -36,14 +37,21 @@ use rocket::Request;
use serde::Deserialize;
use clap::Parser;
use rocket::figment::Figment;
static mut ALIAS: OnceCell<Vec<Alias>> = OnceCell::new();
#[derive(Parser, Debug)]
#[command(about, author)]
struct Args {
#[arg(short, long, default_value = "./alias.json")]
#[arg(long, default_value = "./alias.json")]
alias_file: PathBuf,
#[arg(short, long, default_value = "127.0.0.1")]
address: IpAddr,
#[arg(short, long, default_value = "8080")]
port: u16,
}
#[derive(Deserialize, Clone, Debug)]
@ -128,6 +136,12 @@ async fn main() -> Result<(), rocket::Error> {
)
.unwrap();
}
let _rocket = rocket::build().mount("/", routes![get_page, index]).launch().await?;
let figment = Figment::from(rocket::Config::default())
.merge(("ident", "urouter"))
.merge(("port", args.port))
.merge(("address", args.address));
let _rocket = rocket::custom(figment).mount("/", routes![get_page, index]).launch().await?;
Ok(())
}