feat: add ctx.cookies func

This commit is contained in:
loveuer 2024-01-29 19:16:36 +08:00
parent d2d90e6ffd
commit 083b91bfaa

17
ctx.go
View File

@ -62,6 +62,23 @@ func (c *Ctx) Path(overWrite ...string) string {
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 {
c.index++
s := len(c.handlers)