-
Notifications
You must be signed in to change notification settings - Fork 1
/
cookie.go
101 lines (83 loc) · 1.89 KB
/
cookie.go
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package echo
import (
"net/http"
"time"
)
type (
// Cookie defines the HTTP cookie.
Cookie struct {
name string
value string
path string
domain string
expires time.Time
secure bool
httpOnly bool
sameSite http.SameSite
}
)
// Name returns the cookie name.
func (c *Cookie) Name() string {
return c.name
}
// SetName sets cookie name.
func (c *Cookie) SetName(name string) {
c.name = name
}
// Value returns the cookie value.
func (c *Cookie) Value() string {
return c.value
}
// SetValue sets the cookie value.
func (c *Cookie) SetValue(value string) {
c.value = value
}
// Path returns the cookie path.
func (c *Cookie) Path() string {
return c.path
}
// SetPath sets the cookie path.
func (c *Cookie) SetPath(path string) {
c.path = path
}
// Domain returns the cookie domain.
func (c *Cookie) Domain() string {
return c.domain
}
// SetDomain sets the cookie domain.
func (c *Cookie) SetDomain(domain string) {
c.domain = domain
}
// Expires returns the cookie expiry time.
func (c *Cookie) Expires() time.Time {
return c.expires
}
// SetExpires sets the cookie expiry time.
func (c *Cookie) SetExpires(expires time.Time) {
c.expires = expires
}
// Secure indicates if cookie is Secure.
func (c *Cookie) Secure() bool {
return c.secure
}
// SetSecure sets the cookie as Secure.
func (c *Cookie) SetSecure(secure bool) {
c.secure = secure
}
// HTTPOnly indicates if cookie is HTTPOnly.
func (c *Cookie) HTTPOnly() bool {
return c.httpOnly
}
// SetHTTPOnly sets the cookie as HTTPOnly.
func (c *Cookie) SetHTTPOnly(httpOnly bool) {
c.httpOnly = httpOnly
}
// SameSite indicate if cookie makes impossible for the browser
// to send this cookie along with cross-site requests
func (c *Cookie) SameSite() http.SameSite {
return c.sameSite
}
// SetHTTPOnly sets the cookie SameSite attribute.
func (c *Cookie) SetSameSite(sameSite http.SameSite) {
c.sameSite = sameSite
}