session

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultGetSession

func DefaultGetSession(ctx *mist.Context) (session.Session, bool)

DefaultGetSession 使用默认键名获取会话

func GetSession

func GetSession(ctx *mist.Context, key string) (session.Session, bool)

GetSession 从上下文中获取会话

Types

type MiddlewareBuilder

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

MiddlewareBuilder 会话中间件构建器

func NewMemoryStore

func NewMemoryStore(opts ...Option) (*MiddlewareBuilder, error)

NewMemoryStore 创建基于内存的会话中间件

func NewRedisStore

func NewRedisStore(addr string, password string, db int, keyPrefix string, opts ...Option) (*MiddlewareBuilder, error)

NewRedisStore 创建基于Redis的会话中间件

func (*MiddlewareBuilder) Build

func (b *MiddlewareBuilder) Build() mist.Middleware

Build 构建会话中间件

func (*MiddlewareBuilder) GetManager added in v0.1.20

func (b *MiddlewareBuilder) GetManager() *session.Manager

GetManager 获取会话管理器

func (*MiddlewareBuilder) RunGC added in v0.1.20

func (b *MiddlewareBuilder) RunGC() error

RunGC 手动运行垃圾回收

type Option

type Option func(*MiddlewareBuilder)

Option 会话中间件选项

func WithAutoGC added in v0.1.20

func WithAutoGC(enable bool, interval time.Duration) Option

WithAutoGC 设置是否启用自动垃圾回收

func WithCookieDomain

func WithCookieDomain(domain string) Option

WithCookieDomain 设置cookie域

func WithCookieHTTPOnly

func WithCookieHTTPOnly(httpOnly bool) Option

WithCookieHTTPOnly 设置cookie是否禁止JavaScript访问

func WithCookieName

func WithCookieName(name string) Option

WithCookieName 设置cookie名称

func WithCookiePath

func WithCookiePath(path string) Option

WithCookiePath 设置cookie路径

func WithCookieSameSite

func WithCookieSameSite(sameSite http.SameSite) Option

WithCookieSameSite 设置cookie的SameSite属性

func WithCookieSecure

func WithCookieSecure(secure bool) Option

WithCookieSecure 设置cookie是否只通过HTTPS发送

func WithMaxAge

func WithMaxAge(maxAge int) Option

WithMaxAge 设置会话最大有效期(秒)

func WithSessionKey

func WithSessionKey(key string) Option

WithSessionKey 设置会话在上下文中的键名

Jump to

Keyboard shortcuts

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