-
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...)
}