aboutsummaryrefslogtreecommitdiff
path: root/common/src/config.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-08-02 11:59:36 +0200
committermetamuffin <metamuffin@disroot.org>2023-08-02 11:59:36 +0200
commit0d6a5fb84d3e0016c80baa1849612f550db31a81 (patch)
tree0abe8b419750d74be024a0381a98340c043d5178 /common/src/config.rs
parent59e6e7a6feafaf1dada3054466d415cca047ca1a (diff)
downloadjellything-0d6a5fb84d3e0016c80baa1849612f550db31a81.tar
jellything-0d6a5fb84d3e0016c80baa1849612f550db31a81.tar.bz2
jellything-0d6a5fb84d3e0016c80baa1849612f550db31a81.tar.zst
key config optinal
Diffstat (limited to 'common/src/config.rs')
-rw-r--r--common/src/config.rs29
1 files changed, 21 insertions, 8 deletions
diff --git a/common/src/config.rs b/common/src/config.rs
index b978a1e..da1cfb5 100644
--- a/common/src/config.rs
+++ b/common/src/config.rs
@@ -7,18 +7,31 @@
use serde::{Deserialize, Serialize};
use std::{collections::HashMap, path::PathBuf};
+#[rustfmt::skip]
#[derive(Debug, Deserialize, Serialize, Default)]
pub struct GlobalConfig {
pub brand: String,
pub slogan: String,
+ #[serde(default = "default::asset_path")] pub asset_path: PathBuf,
+ #[serde(default = "default::database_path")] pub database_path: PathBuf,
+ #[serde(default = "default::library_path")] pub library_path: PathBuf,
+ #[serde(default = "default::cache_path")] pub cache_path: PathBuf,
+ #[serde(default = "default::admin_username")] pub admin_username: String,
+ pub admin_password: String,
+ #[serde(default)] pub cookie_key: Option<String>,
+ #[serde(default)] pub session_key: Option<String>,
+ #[serde(default = "default::login_expire")] pub login_expire: i64,
+ #[serde(default)] pub remote_credentials: HashMap<String, (String, String, bool)>,
+}
- pub asset_path: PathBuf,
- pub database_path: PathBuf,
- pub library_path: PathBuf,
+#[rustfmt::skip]
+mod default {
+ use std::path::PathBuf;
- pub admin_username: String,
- pub admin_password: String,
- pub cookie_key: String,
- pub login_expire: i64,
- pub remote_credentials: HashMap<String, (String, String, bool)>,
+ pub fn admin_username() -> String { "admin".into() }
+ pub fn login_expire() -> i64 { 60*60*24 }
+ pub fn asset_path() -> PathBuf { "data/assets".into() }
+ pub fn database_path() -> PathBuf { "data/database".into() }
+ pub fn library_path() -> PathBuf { "data/library".into() }
+ pub fn cache_path() -> PathBuf { "data/cache".into() }
}