MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / Get

Method Get

pkg/web/cookie/cookie.go:71–89  ·  view source on GitHub ↗

Get decodes the cookie into the value. Returns false if the cookie is not there.

(w http.ResponseWriter, r *http.Request, v any)

Source from the content-addressed store, hash-verified

69
70// Get decodes the cookie into the value. Returns false if the cookie is not there.
71func (d *Cookie) Get(w http.ResponseWriter, r *http.Request, v any) (bool, error) {
72 s, err := webmiddleware.GetSecureCookie(r.Context())
73 if err != nil {
74 return false, err
75 }
76
77 cookie, err := r.Cookie(d.Name)
78 if err != nil || cookie.Value == tombstone {
79 return false, nil
80 }
81
82 err = s.Decode(d.Name, cookie.Value, v)
83 if err != nil {
84 d.Remove(w, r)
85 return false, nil
86 }
87
88 return true, nil
89}
90
91// Set the value of the cookie.
92func (d *Cookie) Set(w http.ResponseWriter, r *http.Request, v any) error {

Callers

nothing calls this directly

Calls 4

RemoveMethod · 0.95
GetSecureCookieFunction · 0.92
ContextMethod · 0.65
DecodeMethod · 0.65

Tested by

no test coverage detected