1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
use std::time::Duration;
#[derive(Debug)]
pub struct CookieOptions {
pub name: String,
pub max_age: Duration,
pub domain: Option<String>,
pub path: Option<String>,
pub secure: Option<bool>,
pub http_only: Option<bool>,
pub same_site: Option<String>,
}
impl CookieOptions {
pub fn new() -> Self {
Self {
name: "viz.sid".into(),
max_age: Duration::from_secs(3600 * 24),
domain: None,
path: None,
secure: None,
http_only: None,
same_site: None,
}
}
pub fn with_name(mut self, name: String) -> Self {
self.name = name;
self
}
pub fn with_max_age(mut self, max_age: Duration) -> Self {
self.max_age = max_age;
self
}
pub fn with_domain(mut self, domain: String) -> Self {
self.domain.replace(domain);
self
}
pub fn with_path(mut self, path: String) -> Self {
self.path.replace(path);
self
}
pub fn with_secure(mut self, secure: bool) -> Self {
self.secure.replace(secure);
self
}
pub fn with_http_only(mut self, http_only: bool) -> Self {
self.http_only.replace(http_only);
self
}
pub fn with_same_site(mut self, same_site: String) -> Self {
self.same_site.replace(same_site);
self
}
}