fix: unable to start if config file omit bind/port fields (#294)
This commit is contained in:
parent
ae97c714d6
commit
afdfde01f0
1 changed files with 12 additions and 2 deletions
14
src/args.rs
14
src/args.rs
|
@ -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,
|
||||
|
@ -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()
|
||||
};
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue