MCPcopy Create free account
hub / github.com/kataras/iris / CookieAllowReclaim

Function CookieAllowReclaim

context/context.go:5630–5654  ·  view source on GitHub ↗

CookieAllowReclaim accepts the Context itself. If set it will add the cookie to (on `CookieSet`, `CookieSetKV`, `CookieUpsert`) or remove the cookie from (on `CookieRemove`) the Request object too.

(cookieNames ...string)

Source from the content-addressed store, hash-verified

5628// If set it will add the cookie to (on `CookieSet`, `CookieSetKV`, `CookieUpsert`)
5629// or remove the cookie from (on `CookieRemove`) the Request object too.
5630func CookieAllowReclaim(cookieNames ...string) CookieOption {
5631 return func(ctx *Context, c *http.Cookie, op uint8) {
5632 if op == OpCookieGet {
5633 return
5634 }
5635
5636 if !CookieIncluded(c, cookieNames) {
5637 return
5638 }
5639
5640 switch op {
5641 case OpCookieSet:
5642 // perform upsert on request cookies or is it too much and not worth the cost?
5643 ctx.Request().AddCookie(c)
5644 case OpCookieDel:
5645 cookies := ctx.Request().Cookies()
5646 ctx.Request().Header.Del("Cookie")
5647 for i, v := range cookies {
5648 if v.Name != c.Name {
5649 ctx.Request().AddCookie(cookies[i])
5650 }
5651 }
5652 }
5653 }
5654}
5655
5656// CookieAllowSubdomains set to the Cookie Options
5657// in order to allow subdomains to have access to the cookies.

Callers 2

NewFunction · 0.92
trySetCookieMethod · 0.92

Calls 3

CookieIncludedFunction · 0.85
RequestMethod · 0.80
DelMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…