package web import ( "net/http" "github.com/xlgmokha/x/pkg/cookie" "github.com/xlgmokha/x/pkg/env" "github.com/xlgmokha/x/pkg/x" ) func NewCookie(name, value string, options ...x.Option[*http.Cookie]) *http.Cookie { return x.New[*http.Cookie](x.Prepend[x.Option[*http.Cookie]]( options, 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")), )...) } func ExpireCookie(w http.ResponseWriter, name string) { cookie.Expire(w, name, cookie.WithPath("/"), cookie.WithDomain(env.Fetch("HOST", "localhost")), cookie.WithHttpOnly(true), cookie.WithSecure(true), ) }