cookies

package
v0.84.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SameSiteLaxMode    SameSite = SameSite(http.SameSiteLaxMode)
	SameSiteStrictMode SameSite = SameSite(http.SameSiteStrictMode)

	PartitionTrue  PartitionOption = 1 // Explicitly enable partitioning
	PartitionFalse PartitionOption = 2 // Explicitly disable partitioning

	HttpOnlyTrue  HttpOnlyOption = 1 // Explicitly enable HttpOnly
	HttpOnlyFalse HttpOnlyOption = 2 // Explicitly disable HttpOnly
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientReadableCookie

type ClientReadableCookie[T ~string] struct {
	// contains filtered or unexported fields
}

func NewClientReadableCookie

func NewClientReadableCookie[T ~string](cfg ClientReadableCookieConfig) *ClientReadableCookie[T]

Panics if you fail to provide a Manager or Name via config struct.

func (*ClientReadableCookie) DeleteWithProxy

func (c *ClientReadableCookie) DeleteWithProxy(rp *response.Proxy)

func (*ClientReadableCookie) DeleteWithWriter

func (c *ClientReadableCookie) DeleteWithWriter(w http.ResponseWriter)

func (*ClientReadableCookie) Get

func (c *ClientReadableCookie) Get(r *http.Request) (T, error)

func (*ClientReadableCookie) Name

func (c *ClientReadableCookie) Name() string

func (*ClientReadableCookie) New

func (c *ClientReadableCookie) New(value T) *http.Cookie

func (*ClientReadableCookie) NewDeletion

func (c *ClientReadableCookie) NewDeletion() *http.Cookie

func (*ClientReadableCookie) SetWithProxy

func (c *ClientReadableCookie) SetWithProxy(rp *response.Proxy, value T)

func (*ClientReadableCookie) SetWithWriter

func (c *ClientReadableCookie) SetWithWriter(w http.ResponseWriter, value T)

type ClientReadableCookieConfig

type ClientReadableCookieConfig struct {
	Manager *Manager // Required.
	// Required. Do not prefix the name with "__Host-". Prefixing is handled internally.
	// Final cookie name will be "__{Host|Dev}-{Name}".
	Name      string
	TTL       time.Duration
	SameSite  SameSite
	Partition PartitionOption
}

type ClientReadableCookieNonHostOnly

type ClientReadableCookieNonHostOnly[T ~string] struct {
	// contains filtered or unexported fields
}

func NewClientReadableCookieNonHostOnly

func NewClientReadableCookieNonHostOnly[T ~string](cfg ClientReadableCookieNonHostOnlyConfig) *ClientReadableCookieNonHostOnly[T]

Panics if you fail to provide a Manager or Name via config struct.

func (*ClientReadableCookieNonHostOnly) DeleteWithProxy

func (c *ClientReadableCookieNonHostOnly) DeleteWithProxy(rp *response.Proxy)

func (*ClientReadableCookieNonHostOnly) DeleteWithWriter

func (c *ClientReadableCookieNonHostOnly) DeleteWithWriter(w http.ResponseWriter)

func (*ClientReadableCookieNonHostOnly) Get

func (c *ClientReadableCookieNonHostOnly) Get(r *http.Request) (T, error)

func (*ClientReadableCookieNonHostOnly) Name

func (c *ClientReadableCookieNonHostOnly) Name() string

func (*ClientReadableCookieNonHostOnly) New

func (c *ClientReadableCookieNonHostOnly) New(value T) *http.Cookie

func (*ClientReadableCookieNonHostOnly) NewDeletion

func (c *ClientReadableCookieNonHostOnly) NewDeletion() *http.Cookie

func (*ClientReadableCookieNonHostOnly) SetWithProxy

func (c *ClientReadableCookieNonHostOnly) SetWithProxy(rp *response.Proxy, value T)

func (*ClientReadableCookieNonHostOnly) SetWithWriter

func (c *ClientReadableCookieNonHostOnly) SetWithWriter(w http.ResponseWriter, value T)

type ClientReadableCookieNonHostOnlyConfig

type ClientReadableCookieNonHostOnlyConfig struct {
	Manager   *Manager // Required.
	Name      string
	TTL       time.Duration
	SameSite  SameSite
	Partition PartitionOption
	Path      string
	Domain    string
}

type HttpOnlyOption

type HttpOnlyOption int

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(cfg ManagerConfig) *Manager

func (*Manager) GetIsDev

func (mgr *Manager) GetIsDev() bool

type ManagerConfig

type ManagerConfig struct {
	GetKeyset func() *keyset.Keyset
	GetIsDev  func() bool // Optional. Resolves to false if nil.
	// The manager's default SameSite setting.
	DefaultSameSite SameSite
	// The manager's default for cookie partitioning.
	DefaultPartition PartitionOption
	// The manager's default for the HttpOnly flag on secure cookies.
	DefaultHttpOnly HttpOnlyOption
}

type PartitionOption

type PartitionOption int

type SameSite

type SameSite int

type SecureCookie

type SecureCookie[T any] struct {
	// contains filtered or unexported fields
}

func NewSecureCookie

func NewSecureCookie[T any](cfg SecureCookieConfig) *SecureCookie[T]

Panics if you fail to provide a Manager or Name via config struct.

func (*SecureCookie) DeleteWithProxy

func (c *SecureCookie) DeleteWithProxy(rp *response.Proxy)

func (*SecureCookie) DeleteWithWriter

func (c *SecureCookie) DeleteWithWriter(w http.ResponseWriter)

func (*SecureCookie) Get

func (c *SecureCookie) Get(r *http.Request) (T, error)

func (*SecureCookie) Name

func (c *SecureCookie) Name() string

func (*SecureCookie) New

func (c *SecureCookie) New(data T) (*http.Cookie, error)

func (*SecureCookie) NewDeletion

func (c *SecureCookie) NewDeletion() *http.Cookie

func (*SecureCookie) SetWithProxy

func (c *SecureCookie) SetWithProxy(rp *response.Proxy, value T) error

func (*SecureCookie) SetWithWriter

func (c *SecureCookie) SetWithWriter(w http.ResponseWriter, value T) error

type SecureCookieConfig

type SecureCookieConfig struct {
	Manager *Manager // Required.
	// Required. Do not prefix the name with "__Host-". Prefixing is handled internally.
	// Final cookie name will be "__{Host|Dev}-{Name}".
	Name      string
	TTL       time.Duration
	SameSite  SameSite
	Partition PartitionOption
	HttpOnly  HttpOnlyOption
}

type SecureCookieNonHostOnly

type SecureCookieNonHostOnly[T any] struct {
	// contains filtered or unexported fields
}

func NewSecureCookieNonHostOnly

func NewSecureCookieNonHostOnly[T any](cfg SecureCookieNonHostOnlyConfig) *SecureCookieNonHostOnly[T]

Panics if you fail to provide a Manager or Name via config struct.

func (*SecureCookieNonHostOnly) DeleteWithProxy

func (c *SecureCookieNonHostOnly) DeleteWithProxy(rp *response.Proxy)

func (*SecureCookieNonHostOnly) DeleteWithWriter

func (c *SecureCookieNonHostOnly) DeleteWithWriter(w http.ResponseWriter)

func (*SecureCookieNonHostOnly) Get

func (c *SecureCookieNonHostOnly) Get(r *http.Request) (T, error)

func (*SecureCookieNonHostOnly) Name

func (c *SecureCookieNonHostOnly) Name() string

func (*SecureCookieNonHostOnly) New

func (c *SecureCookieNonHostOnly) New(data T) (*http.Cookie, error)

func (*SecureCookieNonHostOnly) NewDeletion

func (c *SecureCookieNonHostOnly) NewDeletion() *http.Cookie

func (*SecureCookieNonHostOnly) SetWithProxy

func (c *SecureCookieNonHostOnly) SetWithProxy(rp *response.Proxy, value T) error

func (*SecureCookieNonHostOnly) SetWithWriter

func (c *SecureCookieNonHostOnly) SetWithWriter(w http.ResponseWriter, value T) error

type SecureCookieNonHostOnlyConfig

type SecureCookieNonHostOnlyConfig struct {
	Manager   *Manager // Required.
	Name      string
	TTL       time.Duration
	SameSite  SameSite
	Partition PartitionOption
	Path      string
	Domain    string
	HttpOnly  HttpOnlyOption
}

Jump to

Keyboard shortcuts

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