sessions

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Modified = iota
	Destroyed
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractCookieTranscoder added in v0.0.6

type AbstractCookieTranscoder interface {
	Encode(cookieName string, value interface{}) (string, error)
	Decode(cookieName string, cookieValue string, v interface{}) error
}

type AbstractSession

type AbstractSession interface {
	GetId() string
	Set(string, interface{})
	Get(string) interface{}
	Has(string) bool
	Remove(string)
	Destroy() error
	Save() error

	All() map[string]interface{}
}

type AbstractSessionStore

type AbstractSessionStore interface {
	Get(string, interface{}) error
	Save(string, interface{}) error
	Delete(string) error
}

type Config

type Config struct {
	CookieName string
	Expires    time.Duration
}
type Cookie struct {
	// contains filtered or unexported fields
}

func NewCookie

func NewCookie(ctx *fasthttp.RequestCtx, transcoder AbstractCookieTranscoder) *Cookie

func (*Cookie) Delete

func (c *Cookie) Delete(name string)

func (*Cookie) Get

func (c *Cookie) Get(name string) string

func (*Cookie) Reset

func (c *Cookie) Reset(ctx *fasthttp.RequestCtx)

func (*Cookie) Set

func (c *Cookie) Set(name string, value string, maxAge int)

type Session

type Session struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*Session) All added in v0.0.6

func (sess *Session) All() map[string]interface{}

func (*Session) Destroy added in v0.0.6

func (sess *Session) Destroy() error

Destroy 销毁整个sess信息

func (*Session) Get

func (sess *Session) Get(key string) interface{}

func (*Session) GetId added in v0.0.6

func (sess *Session) GetId() string

func (*Session) Has added in v0.0.6

func (sess *Session) Has(key string) bool

Has 检查是否存在Key

func (*Session) Remove

func (sess *Session) Remove(key string)

Remove 移除某个key

func (*Session) Save added in v0.0.6

func (sess *Session) Save() error

func (*Session) Set

func (sess *Session) Set(key string, val interface{})

type Sessions

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

func New

func New(provider AbstractSessionStore, cfg *Config) *Sessions

func (*Sessions) Session

func (m *Sessions) Session(cookie *Cookie) (sess AbstractSession, err error)

Session 获取session对象

Directories

Path Synopsis
providers

Jump to

Keyboard shortcuts

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