Files
k-mood/crates/server/src/config_loader.rs
Gabriel Kaszewski 95739892de
Some checks failed
CI / ci (push) Failing after 1m48s
init
2026-08-25 23:24:36 +02:00

18 lines
526 B
Rust

use config::AppConfig;
const CONFIG_FILE: &str = "config.toml";
pub fn load() -> Result<AppConfig, Box<dyn std::error::Error>> {
let path = std::path::Path::new(CONFIG_FILE);
if path.exists() {
let content = std::fs::read_to_string(path)?;
let config: AppConfig = toml::from_str(&content)?;
tracing::info!(path = CONFIG_FILE, "loaded config from file");
Ok(config)
} else {
tracing::info!("no config file found, using defaults");
Ok(AppConfig::default())
}
}