From abfb37e88dc00ae811b4303c37e9baf51d908362 Mon Sep 17 00:00:00 2001 From: Finn Date: Mon, 14 Oct 2024 19:22:51 -0700 Subject: [PATCH] allow specifying config path via env var --- src/config.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 5198719..b483c54 100644 --- a/src/config.rs +++ b/src/config.rs @@ -31,7 +31,14 @@ fn get_db_uri() -> String { } pub(crate) async fn read_config() -> Config { - let file = File::open("config.json").expect("failed to read config.json"); + let filename = match std::env::var("CONFIG_PATH") { + Ok(value) => value, + Err(_) => "config.json".to_string(), + }; + + log::info!("loading config file from {}", filename); + + let file = File::open(filename).expect("failed to read config file"); let reader = BufReader::new(file); // Read the JSON contents of the file as an instance of `User`.