mirror of
https://github.com/ivabus/urouter
synced 2024-11-25 01:45:10 +03:00
0.3.3: Add port and address options (Nix packaging reasons)
Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
This commit is contained in:
parent
63a4b6b7fc
commit
9122166285
2 changed files with 17 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "urouter"
|
name = "urouter"
|
||||||
version = "0.3.1"
|
version = "0.3.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
repository = "https://github.com/ivabus/urouter"
|
repository = "https://github.com/ivabus/urouter"
|
||||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -27,6 +27,7 @@ extern crate rocket;
|
||||||
|
|
||||||
use rocket::http::Status;
|
use rocket::http::Status;
|
||||||
use std::cell::OnceCell;
|
use std::cell::OnceCell;
|
||||||
|
use std::net::IpAddr;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use rocket::request::{FromRequest, Outcome};
|
use rocket::request::{FromRequest, Outcome};
|
||||||
|
@ -36,14 +37,21 @@ use rocket::Request;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use rocket::figment::Figment;
|
||||||
|
|
||||||
static mut ALIAS: OnceCell<Vec<Alias>> = OnceCell::new();
|
static mut ALIAS: OnceCell<Vec<Alias>> = OnceCell::new();
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(about, author)]
|
#[command(about, author)]
|
||||||
struct Args {
|
struct Args {
|
||||||
#[arg(short, long, default_value = "./alias.json")]
|
#[arg(long, default_value = "./alias.json")]
|
||||||
alias_file: PathBuf,
|
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)]
|
#[derive(Deserialize, Clone, Debug)]
|
||||||
|
@ -128,6 +136,12 @@ async fn main() -> Result<(), rocket::Error> {
|
||||||
)
|
)
|
||||||
.unwrap();
|
.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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue