doc(context): add cookie doc (#1088)

This commit is contained in:
Eason Lin 2017-08-29 03:38:53 +08:00 committed by Javier Provecho Fernandez
parent f1edd2c2d1
commit 8902826696

View File

@ -583,6 +583,9 @@ func (c *Context) GetRawData() ([]byte, error) {
return ioutil.ReadAll(c.Request.Body)
}
// SetCookie adds a Set-Cookie header to the ResponseWriter's headers.
// The provided cookie must have a valid Name. Invalid cookies may be
// silently dropped.
func (c *Context) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool) {
if path == "" {
path = "/"
@ -598,6 +601,10 @@ func (c *Context) SetCookie(name, value string, maxAge int, path, domain string,
})
}
// Cookie returns the named cookie provided in the request or
// ErrNoCookie if not found. And return the named cookie is unescaped.
// If multiple cookies match the given name, only one cookie will
// be returned.
func (c *Context) Cookie(name string) (string, error) {
cookie, err := c.Request.Cookie(name)
if err != nil {