pub struct SessionConfig {
pub secret_key: String,
pub max_age: u64,
pub http_only: bool,
pub secure: bool,
pub cookie_path: String,
pub cookie_domain: Option<String>,
}Expand description
Session 配置
用于配置服务器端会话和 Cookie 行为
§字段说明
secret_key: Session 加密密钥,默认自动生成 32 字节随机密钥max_age: Session 过期时间(秒),默认 86400 秒(24 小时)http_only: Cookie 是否仅允许 HTTP 访问,禁止 JavaScript 读取,默认 truesecure: Cookie 是否仅在 HTTPS 下传输,默认 falsecookie_path: Cookie 有效路径,默认 “/”cookie_domain: Cookie 有效域名,默认 None(当前域名)
§示例
use admin_config::SessionConfig;
let config = SessionConfig::default();
assert_eq!(config.max_age, 86400);
assert!(config.http_only);
assert_eq!(config.cookie_path, "/");Fields§
§secret_key: StringSession 密钥
max_age: u64过期时间(秒)
http_only: bool是否仅 HTTP 访问
secure: bool是否仅 HTTPS 访问
Cookie 路径
Cookie 域名
Trait Implementations§
Source§impl Clone for SessionConfig
impl Clone for SessionConfig
Source§fn clone(&self) -> SessionConfig
fn clone(&self) -> SessionConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SessionConfig
impl Debug for SessionConfig
Source§impl Default for SessionConfig
impl Default for SessionConfig
Source§impl<'de> Deserialize<'de> for SessionConfig
impl<'de> Deserialize<'de> for SessionConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SessionConfig
impl RefUnwindSafe for SessionConfig
impl Send for SessionConfig
impl Sync for SessionConfig
impl Unpin for SessionConfig
impl UnwindSafe for SessionConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more