From 1b8c0cd2283d0b7e24e57d86c9529d97f0879169 Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 30 Apr 2025 12:37:34 -0600 Subject: feat: extract other cookie options --- pkg/web/cookie/new.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pkg/web/cookie/new.go b/pkg/web/cookie/new.go index 7964086..cbca724 100644 --- a/pkg/web/cookie/new.go +++ b/pkg/web/cookie/new.go @@ -31,6 +31,30 @@ func With(with func(*http.Cookie)) pls.Option[*http.Cookie] { } } +func WithPath(value string) pls.Option[*http.Cookie] { + return With(func(c *http.Cookie) { + c.Path = value + }) +} + +func WithHttpOnly(value bool) pls.Option[*http.Cookie] { + return With(func(c *http.Cookie) { + c.HttpOnly = value + }) +} + +func WithSecure(value bool) pls.Option[*http.Cookie] { + return With(func(c *http.Cookie) { + c.Secure = value + }) +} + +func WithDomain(value string) pls.Option[*http.Cookie] { + return With(func(c *http.Cookie) { + c.Domain = value + }) +} + func WithSameSite(value http.SameSite) pls.Option[*http.Cookie] { return With(func(c *http.Cookie) { c.SameSite = value -- cgit v1.2.3