session

package module
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

README

session

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSidFromCookies

func GetSidFromCookies(cook []*http.Cookie, authName string) string

func GetSidFromHeader

func GetSidFromHeader(h *http.Request) (string, string)

func GetSidFromQuery

func GetSidFromQuery(values url.Values, authName string) string

Types

type FileSession

type FileSession struct {
	SError
	// contains filtered or unexported fields
}

func GetNewFileSession

func GetNewFileSession(path string, maxLeftTime int64) *FileSession

func (*FileSession) AutoDestroy

func (fse *FileSession) AutoDestroy()

func (*FileSession) Close

func (fse *FileSession) Close() bool

func (*FileSession) Destroy

func (fse *FileSession) Destroy(sid string) bool

func (*FileSession) Gc

func (fse *FileSession) Gc(maxLeftTime int64) bool

func (*FileSession) GetFileName

func (fse *FileSession) GetFileName(sid string) string

func (*FileSession) Open

func (fse *FileSession) Open(savePath string) bool

func (*FileSession) Read

func (fse *FileSession) Read(sid string) map[string]interface{}

func (*FileSession) SetPrefix added in v1.1.5

func (fse *FileSession) SetPrefix(keyPrefix string)

func (*FileSession) Write

func (fse *FileSession) Write(sid string, data map[string]interface{}) bool

type ISession

type ISession interface {
	Close() bool
	Destroy(sid string) bool
	Gc(maxLeftTime int64) bool
	Open(savePath string) bool
	Read(sid string) map[string]interface{}
	Write(sid string, data map[string]interface{}) bool
	Error(sid string) error
	SetPrefix(keyPrefix string)
}

type IUserSession

type IUserSession interface {
	SetData(data *utils.MapReader) error
	GetData() (data *utils.MapReader, err error)
	GetUserId() int64
	GetProperty(name string) interface{}
	GetAuthName() string
	SetSessionHandler(session ISession) error
	SetUserIdKey(idName string)
}

func GetNewUserSession

func GetNewUserSession(sid string, session ISession) IUserSession

type RedisSession

type RedisSession struct {
	SError
	// contains filtered or unexported fields
}

func GetNewRedisSession

func GetNewRedisSession(client *redis.Client, maxLeftTime int64) *RedisSession

func (*RedisSession) Close

func (rs *RedisSession) Close() bool

func (*RedisSession) Destroy

func (rs *RedisSession) Destroy(sid string) bool

func (*RedisSession) Gc

func (rs *RedisSession) Gc(maxLeftTime int64) bool

func (*RedisSession) Open

func (rs *RedisSession) Open(savePath string) bool

func (*RedisSession) Read

func (rs *RedisSession) Read(sid string) map[string]interface{}

func (*RedisSession) SetPrefix added in v1.1.5

func (rs *RedisSession) SetPrefix(keyPrefix string)

func (*RedisSession) Write

func (rs *RedisSession) Write(sid string, mp map[string]interface{}) bool

type SError

type SError map[string]error

func (SError) Error

func (se SError) Error(sid string) error

func (SError) Remove

func (se SError) Remove(sid string)

func (SError) SetErr

func (se SError) SetErr(sid string, err error)

type UserSession

type UserSession struct {
	UserId   int64            `json:"userId"`
	Property *utils.MapReader `json:"property"`
	Sid      string           `json:"sid"`
	// contains filtered or unexported fields
}

func (*UserSession) GetAuthName

func (s *UserSession) GetAuthName() string

func (*UserSession) GetData

func (s *UserSession) GetData() (data *utils.MapReader, err error)

func (*UserSession) GetProperty

func (s *UserSession) GetProperty(name string) interface{}

func (*UserSession) GetUserId

func (s *UserSession) GetUserId() int64

func (*UserSession) SetData

func (s *UserSession) SetData(data *utils.MapReader) error

func (*UserSession) SetSessionHandler

func (s *UserSession) SetSessionHandler(session ISession) error

func (*UserSession) SetUserIdKey added in v1.1.5

func (s *UserSession) SetUserIdKey(idName string)

Jump to

Keyboard shortcuts

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