Improve configuration

This commit is contained in:
Tobias Reisinger 2024-04-29 04:19:02 +02:00
parent 71498256f6
commit ace4face5a
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
9 changed files with 66 additions and 51 deletions
emgauwa-lib/src

View file

@ -49,9 +49,12 @@ pub fn load<T>(config_name: &str, env_prefix: &str) -> Result<T, EmgauwaError>
where
for<'de> T: serde::Deserialize<'de>,
{
let etc_file =
config::File::with_name(&format!("/etc/emgauwa/{}", config_name)).required(false);
let local_file = config::File::with_name(&format!("./emgauwa-{}", config_name)).required(false);
config::Config::builder()
.add_source(etc_file)
.add_source(local_file)
.add_source(
config::Environment::with_prefix(&format!("EMGAUWA_{}", env_prefix))