MCPcopy Create free account
hub / github.com/BryanMwangi/pine / ReadCookie

Method ReadCookie

pine.go:502–512  ·  view source on GitHub ↗

ReadCookie reads a named cookie from the request.

(name string)

Source from the content-addressed store, hash-verified

500
501// ReadCookie reads a named cookie from the request.
502func (c *Ctx) ReadCookie(name string) (*Cookie, error) {
503 cookieHeader := c.Request.Header.Get("Cookie")
504 if cookieHeader == "" {
505 return nil, nil
506 }
507 cookies := parseCookies(cookieHeader)
508 if cookie, ok := cookies[name]; ok {
509 return &cookie, nil
510 }
511 return nil, nil
512}
513
514func parseCookies(cookieHeader string) map[string]Cookie {
515 cookies := make(map[string]Cookie)

Callers 1

TestReadCookieFunction · 0.95

Calls 2

parseCookiesFunction · 0.85
GetMethod · 0.45

Tested by 1

TestReadCookieFunction · 0.76