Skip to content

Commit

Permalink
fix: unable to start if config file omit bind/port fields (#294)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden authored Nov 25, 2023
1 parent ae97c71 commit afdfde0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,9 @@ pub struct Args {
pub serve_path: PathBuf,
#[serde(deserialize_with = "deserialize_bind_addrs")]
#[serde(rename = "bind")]
#[serde(default = "default_addrs")]
pub addrs: Vec<BindAddr>,
#[serde(default = "default_port")]
pub port: u16,
#[serde(skip)]
pub path_is_file: bool,
Expand Down Expand Up @@ -273,8 +275,8 @@ impl Args {
pub fn parse(matches: ArgMatches) -> Result<Args> {
let mut args = Self {
serve_path: default_serve_path(),
addrs: BindAddr::parse_addrs(&["0.0.0.0", "::"]).unwrap(),
port: 5000,
addrs: default_addrs(),
port: default_port(),
..Default::default()
};

Expand Down Expand Up @@ -479,3 +481,11 @@ where
fn default_serve_path() -> PathBuf {
PathBuf::from(".")
}

fn default_addrs() -> Vec<BindAddr> {
BindAddr::parse_addrs(&["0.0.0.0", "::"]).unwrap()
}

fn default_port() -> u16 {
5000
}

0 comments on commit afdfde0

Please sign in to comment.