use serde::Deserialize;
fn default_true() -> bool {
true
}
fn default_lax() -> String {
"lax".to_string()
}
#[non_exhaustive]
#[derive(Debug, Clone, Deserialize)]
pub struct CookieConfig {
pub secret: String,
#[serde(default = "default_true")]
pub secure: bool,
#[serde(default = "default_true")]
pub http_only: bool,
#[serde(default = "default_lax")]
pub same_site: String,
}
impl Default for CookieConfig {
fn default() -> Self {
Self {
secret: String::new(),
secure: true,
http_only: true,
same_site: "lax".to_string(),
}
}
}
impl CookieConfig {
pub fn new(secret: impl Into<String>) -> Self {
Self {
secret: secret.into(),
secure: true,
http_only: true,
same_site: "lax".to_string(),
}
}
}