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