diff options
Diffstat (limited to 'pkg/web')
| -rw-r--r-- | pkg/web/cookie/new.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/pkg/web/cookie/new.go b/pkg/web/cookie/new.go index d4d0700..a3cb200 100644 --- a/pkg/web/cookie/new.go +++ b/pkg/web/cookie/new.go @@ -5,10 +5,13 @@ import ( "time" "github.com/xlgmokha/x/pkg/env" + "gitlab.com/gitlab-org/software-supply-chain-security/authorization/sparkled/pkg/pls" ) -func New(name, value string, expires time.Time) *http.Cookie { - return &http.Cookie{ +type CookieOption pls.Option[*http.Cookie] + +func New(name, value string, expires time.Time, options ...CookieOption) *http.Cookie { + cookie := &http.Cookie{ Name: name, Value: value, // TODO:: digitally sign the value Expires: expires, @@ -19,4 +22,10 @@ func New(name, value string, expires time.Time) *http.Cookie { SameSite: http.SameSiteStrictMode, Domain: env.Fetch("HOST", "localhost"), } + + for _, option := range options { + cookie = option(cookie) + } + + return cookie } |
