-
Notifications
You must be signed in to change notification settings - Fork 11
/
context_x_session.go
49 lines (38 loc) · 1.04 KB
/
context_x_session.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
package echo
import "net/http"
func (c *xContext) Session() Sessioner {
return c.sessioner
}
func (c *xContext) Flash(names ...string) (r interface{}) {
if v := c.sessioner.Flashes(names...); len(v) > 0 {
r = v[len(v)-1]
}
return r
}
func (c *xContext) SetCookieOptions(opts *CookieOptions) {
c.SessionOptions().CookieOptions = opts
}
func (c *xContext) CookieOptions() *CookieOptions {
return c.SessionOptions().CookieOptions
}
func (c *xContext) SetSessionOptions(opts *SessionOptions) {
c.sessionOptions = opts
}
func (c *xContext) SessionOptions() *SessionOptions {
if c.sessionOptions == nil {
c.sessionOptions = DefaultSessionOptions
}
return c.sessionOptions
}
func (c *xContext) NewCookie(key string, value string) *http.Cookie {
return NewCookie(key, value, c.CookieOptions())
}
func (c *xContext) Cookie() Cookier {
return c.cookier
}
func (c *xContext) GetCookie(key string) string {
return c.cookier.Get(key)
}
func (c *xContext) SetCookie(key string, val string, args ...interface{}) {
c.cookier.Set(key, val, args...)
}