feat: init

This commit is contained in:
zhenyi
2026-06-07 11:30:56 +08:00
commit 563381c1ca
361 changed files with 41327 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
use crate::config::AppConfig;
use crate::error::AppResult;
impl AppConfig {
pub fn session_cookie_name(&self) -> AppResult<String> {
self.get_env_or("APP_SESSION_COOKIE_NAME", "sid".to_string())
}
pub fn session_cookie_secure(&self) -> AppResult<bool> {
self.get_env_or("APP_SESSION_COOKIE_SECURE", true)
}
pub fn session_cookie_http_only(&self) -> AppResult<bool> {
self.get_env_or("APP_SESSION_COOKIE_HTTP_ONLY", true)
}
pub fn session_cookie_same_site(&self) -> AppResult<String> {
self.get_env_or("APP_SESSION_COOKIE_SAME_SITE", "Lax".to_string())
}
pub fn session_cookie_path(&self) -> AppResult<String> {
self.get_env_or("APP_SESSION_COOKIE_PATH", "/".to_string())
}
pub fn session_cookie_domain(&self) -> AppResult<Option<String>> {
self.get_env::<String>("APP_SESSION_COOKIE_DOMAIN")
}
pub fn session_ttl_secs(&self) -> AppResult<u64> {
self.get_env_or("APP_SESSION_TTL_SECS", 86400)
}
pub fn session_max_age_secs(&self) -> AppResult<Option<u64>> {
self.get_env::<u64>("APP_SESSION_MAX_AGE_SECS")
}
}