kanidm/src/lib/config.rs

39 lines
975 B
Rust
Raw Normal View History

use std::path::PathBuf;
2018-11-26 07:13:22 +01:00
#[derive(Serialize, Deserialize, Debug)]
pub struct Configuration {
pub address: String,
pub domain: String,
2018-11-26 07:13:22 +01:00
pub threads: usize,
pub db_path: String,
pub maximum_request: usize,
// db type later
pub secure_cookies: bool,
2018-11-26 07:13:22 +01:00
}
impl Configuration {
pub fn new() -> Self {
Configuration {
address: String::from("127.0.0.1:8080"),
domain: String::from("127.0.0.1"),
2018-11-26 07:13:22 +01:00
threads: 8,
db_path: String::from(""),
maximum_request: 262144, // 256k
// log type
// log path
// TODO: default true in prd
secure_cookies: false,
2018-11-26 07:13:22 +01:00
}
}
pub fn update_db_path(&mut self, p: &PathBuf) {
match p.to_str() {
Some(p) => self.db_path = p.to_string(),
None => {
error!("Invalid DB path supplied");
std::process::exit(1);
}
}
}
2018-11-26 07:13:22 +01:00
}