Documentation ¶
Index ¶
- Constants
- func GetSessionSize(c *gin.Context) int
- func UseSession(options Options, store gonicSession.Store, sessionHandler func(Session, int)) func(*gin.Context)
- type Manager
- type MemSession
- func (session *MemSession) Get(key interface{}) (value interface{}, ok bool)
- func (session *MemSession) GetId() string
- func (session *MemSession) GetLastAccessTime() int64
- func (session *MemSession) GetMaskedSessionId() string
- func (session *MemSession) Invalidate()
- func (session *MemSession) Set(key interface{}, value interface{}) error
- type Options
- type Session
Constants ¶
View Source
const ( Created = 1 Destroyed = 2 Update = 3 )
View Source
const DefaultKey = "session-key"
Variables ¶
This section is empty.
Functions ¶
func GetSessionSize ¶
func UseSession ¶
func UseSession(options Options, store gonicSession.Store, sessionHandler func(Session, int)) func(*gin.Context)
UseSession gin session middleware
Types ¶
type Manager ¶
type Manager struct { SessionCreator func(r *http.Request, w http.ResponseWriter) (Session, error) // contains filtered or unexported fields }
Manager manage the created sessions
func NewManager ¶
func NewManager(options Options, SessionCreator func(r *http.Request, w http.ResponseWriter) (Session, error), sessionHandler func(Session, int)) *Manager
NewManager init new session manager and start gc
func (*Manager) CreateSession ¶
func (*Manager) GetSession ¶
GetSession get memory session store http request
func (*Manager) GetSessionById ¶
GetSessionById get memory session store by sid
func (*Manager) GetSessionSize ¶
GetSessionSize get all managed session size
type MemSession ¶
type MemSession struct {
// contains filtered or unexported fields
}
func (*MemSession) Get ¶
func (session *MemSession) Get(key interface{}) (value interface{}, ok bool)
func (*MemSession) GetId ¶
func (session *MemSession) GetId() string
func (*MemSession) GetLastAccessTime ¶
func (session *MemSession) GetLastAccessTime() int64
func (*MemSession) GetMaskedSessionId ¶
func (session *MemSession) GetMaskedSessionId() string
GetMaskedSessionId session id is critical information, we should mask it
func (*MemSession) Invalidate ¶
func (session *MemSession) Invalidate()
Invalidate invalidate session will remove session from registry
func (*MemSession) Set ¶
func (session *MemSession) Set(key interface{}, value interface{}) error
type Session ¶
type Session interface { GetId() string GetMaskedSessionId() string GetLastAccessTime() int64 Get(key interface{}) (value interface{}, ok bool) Set(key interface{}, value interface{}) error Invalidate() }
func CreateMemSession ¶
func GetSession ¶
GetSession get the session from gin context
func NewSession ¶
Click to show internal directories.
Click to hide internal directories.