cookie

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Carrier

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

Carrier 基于 Cookie 的 Token 载体

func NewCarrier

func NewCarrier(cookieName string, opts ...Option) *Carrier

NewCarrier 创建 Cookie Token 载体 cookieName: Cookie 名称,默认为 "gint_token"

func (*Carrier) Clear

func (c *Carrier) Clear(ctx *gctx.Context)

Clear 清除 Cookie

func (*Carrier) Extract

func (c *Carrier) Extract(ctx *gctx.Context) string

Extract 从 Cookie 中提取 Token

func (*Carrier) Inject

func (c *Carrier) Inject(ctx *gctx.Context, token string)

Inject 将 Token 注入到 Cookie 中

type Option

type Option func(*Carrier)

Option Cookie 配置选项

func WithDomain

func WithDomain(domain string) Option

WithDomain 设置 Cookie 域名

func WithHttpOnly

func WithHttpOnly(httpOnly bool) Option

WithHttpOnly 设置是否禁止 JavaScript 访问

func WithMaxAge

func WithMaxAge(maxAge int) Option

WithMaxAge 设置 Cookie 最大存活时间

func WithPath

func WithPath(path string) Option

WithPath 设置 Cookie 路径

func WithSecure

func WithSecure(secure bool) Option

WithSecure 设置是否只在 HTTPS 下传输

Jump to

Keyboard shortcuts

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