/
cookie.go
41 lines (35 loc) · 913 Bytes
/
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
package gor
import (
"net/http"
"time"
)
// Cookie like http.Cookie but remove name and value
type Cookie struct {
Path string // optional
Domain string // optional
Expires time.Time // optional
RawExpires string // for reading cookies only
// MaxAge=0 means no 'Max-Age' attribute specified.
// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'
// MaxAge>0 means Max-Age attribute present and given in seconds
MaxAge int
Secure bool
HTTPOnly bool
Raw string
Unparsed []string // Raw text of unparsed attribute-value pairs
}
func (c *Cookie) toHTTPCookie(key, val string) *http.Cookie {
return &http.Cookie{
Name: key,
Value: val,
Path: c.Path,
Domain: c.Domain,
Expires: c.Expires,
RawExpires: c.RawExpires,
MaxAge: c.MaxAge,
Secure: c.Secure,
HttpOnly: c.HTTPOnly,
Raw: c.Raw,
Unparsed: c.Unparsed,
}
}