فهرست منبع

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

Eason Lin 8 سال پیش
والد
کامیت
8902826696
1فایلهای تغییر یافته به همراه7 افزوده شده و 0 حذف شده
  1. 7 0
      context.go

+ 7 - 0
context.go

@@ -583,6 +583,9 @@ func (c *Context) GetRawData() ([]byte, error) {
 	return ioutil.ReadAll(c.Request.Body)
 	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) {
 func (c *Context) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool) {
 	if path == "" {
 	if path == "" {
 		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) {
 func (c *Context) Cookie(name string) (string, error) {
 	cookie, err := c.Request.Cookie(name)
 	cookie, err := c.Request.Cookie(name)
 	if err != nil {
 	if err != nil {