From eda6ff247f346bc0679c80348984ddedb94515a7 Mon Sep 17 00:00:00 2001 From: arshamalh Date: Fri, 10 Jun 2022 04:17:20 +0430 Subject: [PATCH 1/2] Cookies added to return all cookies at once. --- context.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/context.go b/context.go index 46bf1133..ef8649ca 100644 --- a/context.go +++ b/context.go @@ -897,6 +897,16 @@ func (c *Context) Cookie(name string) (string, error) { return val, nil } +// Cookies parses and returns the HTTP cookies sent with the request. +func (c *Context) Cookies() []string { + var cookies []string + for _, cookie := range c.Request.Cookies() { + val, _ := url.QueryUnescape(cookie.Value) + cookies = append(cookies, val) + } + return cookies +} + // Render writes the response headers and calls render.Render to render data. func (c *Context) Render(code int, r render.Render) { c.Status(code) From 5f7e9d50f589dd826ed75a08989cc4542c51fcda Mon Sep 17 00:00:00 2001 From: arshamalh Date: Fri, 10 Jun 2022 04:34:04 +0430 Subject: [PATCH 2/2] type of returned cookies changed. --- context.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/context.go b/context.go index ef8649ca..2b1a12eb 100644 --- a/context.go +++ b/context.go @@ -898,11 +898,11 @@ func (c *Context) Cookie(name string) (string, error) { } // Cookies parses and returns the HTTP cookies sent with the request. -func (c *Context) Cookies() []string { - var cookies []string +func (c *Context) Cookies() map[string]string { + cookies := make(map[string]string) for _, cookie := range c.Request.Cookies() { val, _ := url.QueryUnescape(cookie.Value) - cookies = append(cookies, val) + cookies[cookie.Name] = val } return cookies }