2023-11-23 15:00:24 +00:00
|
|
|
use emgauwa_lib::{constants, utils};
|
2023-11-19 17:54:27 +00:00
|
|
|
use serde_derive::Deserialize;
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
|
|
#[serde(default)]
|
|
|
|
#[allow(unused)]
|
|
|
|
pub struct Logging {
|
|
|
|
pub level: String,
|
|
|
|
pub file: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
|
|
#[serde(default)]
|
|
|
|
#[allow(unused)]
|
|
|
|
pub struct Settings {
|
|
|
|
pub database: String,
|
|
|
|
pub port: u16,
|
|
|
|
pub host: String,
|
2023-11-24 00:10:33 +00:00
|
|
|
pub origins: Vec<String>,
|
2023-11-19 17:54:27 +00:00
|
|
|
pub logging: Logging,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Settings {
|
|
|
|
fn default() -> Self {
|
|
|
|
Settings {
|
|
|
|
database: String::from("sqlite://emgauwa-core.sqlite"),
|
2023-11-23 02:36:14 +00:00
|
|
|
port: constants::DEFAULT_PORT,
|
2023-11-19 17:54:27 +00:00
|
|
|
host: String::from("127.0.0.1"),
|
2023-11-24 00:10:33 +00:00
|
|
|
origins: Vec::new(),
|
2023-11-19 17:54:27 +00:00
|
|
|
logging: Logging::default(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for Logging {
|
|
|
|
fn default() -> Self {
|
|
|
|
Logging {
|
|
|
|
level: String::from("info"),
|
|
|
|
file: String::from("stdout"),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-22 19:06:20 +00:00
|
|
|
pub fn init() -> Settings {
|
2023-11-23 15:00:24 +00:00
|
|
|
utils::load_settings("core", "CORE")
|
2023-11-19 17:54:27 +00:00
|
|
|
}
|