Config defaults
This commit is contained in:
parent
3ab0e0fe4e
commit
a97c62ae9b
|
@ -8,23 +8,50 @@ const CONFIG_FILE: &str = "config.json";
|
|||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Config {
|
||||
#[serde(default = "Config::default_admin_passwords")]
|
||||
pub admin_passwords: Vec<String>,
|
||||
#[serde(default = "Config::default_cookies_https_only")]
|
||||
pub cookies_https_only: bool,
|
||||
#[serde(default = "Config::default_cookies_domain")]
|
||||
pub cookies_domain: Option<String>,
|
||||
#[serde(default = "Config::default_listen")]
|
||||
pub listen: SocketAddr,
|
||||
#[serde(default = "Config::default_root_url")]
|
||||
pub root_url: String,
|
||||
#[serde(default = "Config::default_title")]
|
||||
pub title: String,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
fn default_admin_passwords() -> Vec<String> {
|
||||
vec![]
|
||||
}
|
||||
fn default_cookies_https_only() -> bool {
|
||||
false
|
||||
}
|
||||
fn default_cookies_domain() -> Option<String> {
|
||||
None
|
||||
}
|
||||
fn default_listen() -> SocketAddr {
|
||||
SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 10353)
|
||||
}
|
||||
fn default_root_url() -> String {
|
||||
"/".into()
|
||||
}
|
||||
fn default_title() -> String {
|
||||
"ĞMarché".into()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
admin_passwords: vec![],
|
||||
cookies_https_only: false,
|
||||
cookies_domain: None,
|
||||
listen: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 10353),
|
||||
root_url: String::from("/"),
|
||||
title: String::from("ĞMarché"),
|
||||
admin_passwords: Self::default_admin_passwords(),
|
||||
cookies_https_only: Self::default_cookies_https_only(),
|
||||
cookies_domain: Self::default_cookies_domain(),
|
||||
listen: Self::default_listen(),
|
||||
root_url: Self::default_root_url(),
|
||||
title: Self::default_title(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue