allow specifying config path via env var
All checks were successful
/ build-container (push) Successful in 5m33s

This commit is contained in:
Finn 2024-10-14 19:22:51 -07:00
parent d03734892d
commit abfb37e88d

View file

@ -31,7 +31,14 @@ fn get_db_uri() -> String {
} }
pub(crate) async fn read_config() -> Config { 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); let reader = BufReader::new(file);
// Read the JSON contents of the file as an instance of `User`. // Read the JSON contents of the file as an instance of `User`.