cookie

package
v1.8.0-rc1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SameSiteLax    = "Lax"
	SameSiteStrict = "Strict"
	SameSiteNone   = "None"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppsecCookie

type AppsecCookie struct {
	Name         string
	Expiration   int64
	Val          string
	PathVal      string
	DomainName   string
	SecureFlag   bool
	HttpOnlyFlag bool
	SameSiteMode string
}

AppsecCookie is the value-type passed around through expr rules to build up a Set-Cookie header. Rule authors construct it via cookie.AppsecCookie(name) and chain the builder methods below; the final String() call renders it to a Set-Cookie-compatible string.

func Cookie(name string) *AppsecCookie

Cookie is a short alias for NewAppsecCookie.

func NewAppsecCookie

func NewAppsecCookie(name string) *AppsecCookie

NewAppsecCookie returns a cookie pre-populated with sensible defaults. Defaults: Path "/", SameSite=Lax, session lifetime, not secure/httponly unless set.

func (*AppsecCookie) Domain

func (c *AppsecCookie) Domain(domain string) *AppsecCookie

Domain sets the cookie Domain attribute. Leave unset to scope the cookie to the request host.

func (*AppsecCookie) ExpiresAt

func (c *AppsecCookie) ExpiresAt(t time.Time) *AppsecCookie

ExpiresAt sets an absolute expiration time (unix seconds).

func (*AppsecCookie) ExpiresIn

func (c *AppsecCookie) ExpiresIn(d time.Duration) *AppsecCookie

ExpiresIn sets the expiration relative to now.

func (*AppsecCookie) HttpOnly

func (c *AppsecCookie) HttpOnly() *AppsecCookie

HttpOnly marks the cookie HttpOnly so it cannot be read from JS.

func (*AppsecCookie) Path

func (c *AppsecCookie) Path(path string) *AppsecCookie

Path sets the cookie Path attribute; empty input restores the default ("/").

func (*AppsecCookie) SameSite

func (c *AppsecCookie) SameSite(mode string) *AppsecCookie

SameSite sets the SameSite mode (Lax / Strict / None). Unknown values are passed through verbatim; validation happens on String() rendering.

func (*AppsecCookie) Secure

func (c *AppsecCookie) Secure() *AppsecCookie

Secure marks the cookie Secure. Required when SameSite=None.

func (*AppsecCookie) String

func (c *AppsecCookie) String() string

String formats the cookie into a Set-Cookie compatible string.

func (*AppsecCookie) Value

func (c *AppsecCookie) Value(value string) *AppsecCookie

Value sets the cookie's value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL