Add settings and constants

This commit is contained in:
Tobias Reisinger 2023-11-23 03:36:14 +01:00
parent e419923939
commit ee68405874
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
6 changed files with 26 additions and 8 deletions
emgauwa-core/src

View file

@ -1,4 +1,5 @@
use config::Config;
use emgauwa_lib::constants;
use serde_derive::Deserialize;
#[derive(Clone, Debug, Deserialize)]
@ -23,7 +24,7 @@ impl Default for Settings {
fn default() -> Self {
Settings {
database: String::from("sqlite://emgauwa-core.sqlite"),
port: 5000,
port: constants::DEFAULT_PORT,
host: String::from("127.0.0.1"),
logging: Logging::default(),
}
@ -44,11 +45,11 @@ pub fn init() -> Settings {
.add_source(config::File::with_name("emgauwa-core"))
.add_source(
config::Environment::with_prefix("EMGAUWA_CORE")
.prefix_separator("_")
.prefix_separator("__")
.separator("__"),
)
.build()
.unwrap()
.try_deserialize::<Settings>()
.unwrap_or_else(|_| panic!("Error reading settings."))
.expect("Error reading settings.")
}