Configurable path
This commit is contained in:
1 parent
38c5102c37
commit
c0d2e1d48f
2 files changed
+7
-6
No files matched your search
+4
-2
@@ -1,10 +1,11 @@
|
||||
use std::env;
|
||||
use std::{env, path::PathBuf};
|
||||
|
||||
use secrecy::SecretString;
|
||||
use thiserror::Error;
|
||||
|
||||
pub struct Config {
|
||||
pub server_secret: SecretString,
|
||||
pub state_dir: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
@@ -19,7 +20,8 @@ impl Config {
|
||||
pub fn new() -> Result<Self, ConfigError> {
|
||||
dotenvy::dotenv().map_err(|err| ConfigError::Unknown(err.into()))?;
|
||||
let server_secret = env::var("SERVER_SECRET").map(SecretString::from).map_err(|_| ConfigError::MissingServerSecret)?;
|
||||
Ok(Self{server_secret})
|
||||
let state_dir = env::var("RUKOSYNC_STATE_DIR").map_or_else(|_| PathBuf::from("/tmp/"), PathBuf::from);
|
||||
Ok(Self{server_secret, state_dir})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user