From 760c930f6dbac60b20795e027bfff4a9e55d67b2 Mon Sep 17 00:00:00 2001 From: donpat1to Date: Fri, 29 Aug 2025 23:33:00 +0200 Subject: [PATCH] parsing environment variables --- WatcherAgent/src/config.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/WatcherAgent/src/config.rs b/WatcherAgent/src/config.rs index dd9fd17..5b6e038 100644 --- a/WatcherAgent/src/config.rs +++ b/WatcherAgent/src/config.rs @@ -15,20 +15,21 @@ pub struct AppSettings { } #[derive(Debug, Deserialize, Clone)] - pub struct ServerSettings { pub url: String, } impl Settings { pub fn new() -> Result { - // Load .env file first dotenvy::dotenv().ok(); - // Merge settings from multiple sources let builder = config::Config::builder() - .add_source(config::File::with_name("Settings").required(false)) // Settings.toml optional - .add_source(Environment::default().separator("_")); + .add_source(File::with_name("Settings").required(false)) + .add_source( + Environment::default() + .separator("_") // "APP" maps to struct `app` + .try_parsing(true), + ); builder.build()?.try_deserialize() }