def cookie.put

bend-kit-http@0.38.4.0 · http.bend:2356

import bend-kit-http@0.38.4.0/http.bend as Http
import Base

2356# cs with the cookie c replaces swapped for c (keeping its place, so its creation order), or c last.
2357# A c that is not live only removes the old one: that is how a server deletes a cookie.
2358def cookie.put(cs: List<&2, Cookie>, +c: Cookie, +live: Bool) -> List<&2, Cookie>:
2359  match cs:
2360    case Nil{}:
2361      Bool.pick(List<&2, Cookie>, live, [c], Nil{})
2362    case Con{+o, +t}:
2363      Bool.pick(List<&2, Cookie>, cookie.same(o, c), Bool.pick(List<&2, Cookie>, live, Con{c, t}, t), Con{o, cookie.put(t, c, live)})

Uses (5)

Used by (1)