gitdataai/libs/config/storage.rs

40 lines
1.0 KiB
Rust

use crate::AppConfig;
impl AppConfig {
pub fn storage_path(&self) -> String {
self.env
.get("STORAGE_PATH")
.cloned()
.unwrap_or_else(|| "/data/files".to_string())
}
pub fn storage_public_url(&self) -> String {
self.env
.get("STORAGE_PUBLIC_URL")
.cloned()
.unwrap_or_else(|| "/files".to_string())
}
pub fn storage_max_file_size(&self) -> usize {
self.env
.get("STORAGE_MAX_FILE_SIZE")
.and_then(|s| s.parse::<usize>().ok())
.unwrap_or(10 * 1024 * 1024) // 10MB default
}
pub fn vapid_public_key(&self) -> Option<String> {
self.env.get("VAPID_PUBLIC_KEY").cloned()
}
pub fn vapid_private_key(&self) -> Option<String> {
self.env.get("VAPID_PRIVATE_KEY").cloned()
}
pub fn vapid_sender_email(&self) -> String {
self.env
.get("VAPID_SENDER_EMAIL")
.cloned()
.unwrap_or_else(|| "mailto:admin@example.com".to_string())
}
}