summaryrefslogtreecommitdiff
path: root/pkg/web/cookie/new.go
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-05-07 08:46:32 -0700
committermo khan <mo@mokhan.ca>2025-05-07 08:46:32 -0700
commitf417e03cb09024743baf2f749e4309032afd5f39 (patch)
treec2449a35404af96a2395f8716a0901a80c63bf94 /pkg/web/cookie/new.go
parentd3cb17f8032d95f0f8805a0ce74fe5fc41714bb8 (diff)
refactor: delegate to cookie package
Diffstat (limited to 'pkg/web/cookie/new.go')
-rw-r--r--pkg/web/cookie/new.go18
1 files changed, 9 insertions, 9 deletions
diff --git a/pkg/web/cookie/new.go b/pkg/web/cookie/new.go
index 8c04dd6..be0241d 100644
--- a/pkg/web/cookie/new.go
+++ b/pkg/web/cookie/new.go
@@ -3,6 +3,7 @@ package cookie
import (
"net/http"
+ "github.com/xlgmokha/x/pkg/cookie"
"github.com/xlgmokha/x/pkg/env"
"github.com/xlgmokha/x/pkg/x"
)
@@ -10,15 +11,14 @@ import (
func New(name, value string, options ...x.Option[*http.Cookie]) *http.Cookie {
options = x.Prepend[x.Option[*http.Cookie]](
options,
- With(func(c *http.Cookie) {
- c.Name = name
- c.Value = value // TODO:: digitally sign the value
- }),
- WithPath("/"),
- WithHttpOnly(true),
- WithSecure(true),
- WithSameSite(http.SameSiteDefaultMode),
- WithDomain(env.Fetch("HOST", "localhost")),
+ cookie.WithName(name),
+ cookie.WithValue(value), // TODO:: digitally sign the value
+ cookie.WithPath("/"),
+ cookie.WithHttpOnly(true),
+ cookie.WithSecure(true),
+ cookie.WithSameSite(http.SameSiteDefaultMode),
+ cookie.WithDomain(env.Fetch("HOST", "localhost")),
)
+
return x.New[*http.Cookie](options...)
}