feat: add ctx.cookies func
This commit is contained in:
parent
d2d90e6ffd
commit
083b91bfaa
17
ctx.go
17
ctx.go
@ -62,6 +62,23 @@ func (c *Ctx) Path(overWrite ...string) string {
|
|||||||
return path
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Ctx) Cookies(key string, defaultValue ...string) string {
|
||||||
|
var (
|
||||||
|
dv = ""
|
||||||
|
)
|
||||||
|
|
||||||
|
if len(defaultValue) > 0 {
|
||||||
|
dv = defaultValue[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
cookie, err := c.Request.Cookie(key)
|
||||||
|
if err != nil || cookie.Value == "" {
|
||||||
|
return dv
|
||||||
|
}
|
||||||
|
|
||||||
|
return cookie.Value
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Ctx) Next() error {
|
func (c *Ctx) Next() error {
|
||||||
c.index++
|
c.index++
|
||||||
s := len(c.handlers)
|
s := len(c.handlers)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user