mirror of
https://github.com/nais/wonderwall.git
synced 2026-05-11 02:47:05 +00:00
Co-Authored-By: Youssef Bel Mekki <youssef.bel.mekki@nav.no> Co-Authored-By: Tommy Trøen <tommy.troen@nav.no>
41 lines
635 B
Go
41 lines
635 B
Go
package cookie
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
type Options struct {
|
|
ExpiresIn time.Duration
|
|
Domain string
|
|
SameSite http.SameSite
|
|
Secure bool
|
|
}
|
|
|
|
func DefaultOptions() Options {
|
|
return Options{
|
|
SameSite: http.SameSiteLaxMode,
|
|
Secure: true,
|
|
}
|
|
}
|
|
|
|
func (o Options) WithDomain(domain string) Options {
|
|
o.Domain = domain
|
|
return o
|
|
}
|
|
|
|
func (o Options) WithSameSite(sameSite http.SameSite) Options {
|
|
o.SameSite = sameSite
|
|
return o
|
|
}
|
|
|
|
func (o Options) WithExpiresIn(expiresIn time.Duration) Options {
|
|
o.ExpiresIn = expiresIn
|
|
return o
|
|
}
|
|
|
|
func (o Options) WithSecure(secure bool) Options {
|
|
o.Secure = secure
|
|
return o
|
|
}
|