diff options
| author | mo khan <mo@mokhan.ca> | 2025-04-30 12:43:52 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-04-30 12:43:52 -0600 |
| commit | 86830bbc2f382ff837b1068bd097d5e97c9ec2aa (patch) | |
| tree | cb6c882a15812b078e0ca328bb5053f2886d3fa4 /pkg | |
| parent | 1b8c0cd2283d0b7e24e57d86c9529d97f0879169 (diff) | |
refactor: using existing helpers
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/pls/option.go | 4 | ||||
| -rw-r--r-- | pkg/web/cookie/new.go | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/pkg/pls/option.go b/pkg/pls/option.go index 07c6b22..e4fb245 100644 --- a/pkg/pls/option.go +++ b/pkg/pls/option.go @@ -12,6 +12,6 @@ func New[T any](options ...Option[T]) T { return item } -func Prepend[T any](items []T, item T) []T { - return append([]T{item}, items...) +func Prepend[T any](rest []T, beginning ...T) []T { + return append(beginning, rest...) } diff --git a/pkg/web/cookie/new.go b/pkg/web/cookie/new.go index cbca724..f4b049e 100644 --- a/pkg/web/cookie/new.go +++ b/pkg/web/cookie/new.go @@ -14,12 +14,12 @@ func New(name, value string, options ...pls.Option[*http.Cookie]) *http.Cookie { With(func(c *http.Cookie) { c.Name = name c.Value = value // TODO:: digitally sign the value - c.Path = "/" - c.HttpOnly = true - c.Secure = true - c.SameSite = http.SameSiteStrictMode - c.Domain = env.Fetch("HOST", "localhost") }), + WithPath("/"), + WithHttpOnly(true), + WithSecure(true), + WithSameSite(http.SameSiteStrictMode), + WithDomain(env.Fetch("HOST", "localhost")), ) return pls.New[*http.Cookie](options...) } |
