Documentation ¶
Index ¶
- Variables
- func Debug(flag bool)
- func Invalidate(s *Session) error
- func Malloc(v *Values)
- func NewCookie() *http.Cookie
- func Open(opt Configure)
- func StoreFactory(opt Options, store Storage)
- type Config
- type Configure
- type Options
- type RAMOption
- type RDSOption
- type RamStore
- type RdsStore
- type Session
- type Storage
- type Values
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // DefaultRAMOptions default RAM config parameter option. DefaultRAMOptions = &RAMOption{ option: defaultOption, } // NewRDSOptions default RDS config parameter option. NewRDSOptions = func(ip string, port uint16, passwd string, opts ...func(*RDSOption)) *RDSOption { var rdsopt RDSOption rdsopt.option = defaultOption rdsopt.Index = 6 rdsopt.Prefix = prefix rdsopt.PoolSize = 10 rdsopt.Password = passwd rdsopt.Address = fmt.Sprintf("%s:%v", ip, port) for _, opt := range opts { opt(&rdsopt) } return &rdsopt } // WithIndex set redis database number WithIndex = func(number uint8) func(*RDSOption) { return func(r *RDSOption) { r.Index = number } } // WithPoolSize set redis connection pool size WithPoolSize = func(poolsize uint8) func(*RDSOption) { return func(r *RDSOption) { r.PoolSize = poolsize } } // WithPrefix set redis key prefix WithPrefix = func(prefix string) func(*RDSOption) { return func(r *RDSOption) { r.Prefix = prefix } } // WithOpts set base option WithOpts = func(opt Options) func(*RDSOption) { return func(r *RDSOption) { r.option = opt.option } } )
View Source
var ( WithLifeTime = func(d time.Duration) func(*Options) { return func(o *Options) { o.LifeTime = d } } WithCookieName = func(cn string) func(*Options) { return func(o *Options) { o.CookieName = cn } } WithPath = func(path string) func(*Options) { return func(o *Options) { o.Path = path } } WithHttpOnly = func(b bool) func(*Options) { return func(o *Options) { o.HttpOnly = b } } WithSecure = func(b bool) func(*Options) { return func(o *Options) { o.Secure = b } } WithDomain = func(domain string) func(*Options) { return func(o *Options) { o.Domain = domain } } )
View Source
var ( ErrKeyNoData = errors.New("key no data") ErrSessionNoData = errors.New("session no data") ErrIsEmpty = errors.New("key or session id is empty") ErrAlreadyExpired = errors.New("session already expired") ErrRemoveSessionFail = errors.New("remove session fail") ErrMigrateSessionFail = errors.New("migrate session fail") )
Functions ¶
func StoreFactory ¶
StoreFactory Initialize custom storage media
Types ¶
type Config ¶
type Config struct { RDSOption // contains filtered or unexported fields }
config is session storage config parameter.
type Configure ¶
type Configure interface {
Parse() (cfg *Config)
}
Configure is session storage config parameter parser.
type Options ¶
type Options struct {
// contains filtered or unexported fields
}
Options type is default config parameter option.
func NewOptions ¶
NewOptions: Initialize default config.
type RAMOption ¶
type RAMOption struct {
// contains filtered or unexported fields
}
RAMOption is RAM storage config parameter option.
type RDSOption ¶
type RDSOption struct { Index uint8 `json:"db_index" verify:"true" msg:"redis database number required"` Prefix string `json:"prefix" verify:"true" msg:"redis prefix required"` Address string `json:"address" verify:"true" msg:"redis server ip required"` Password string `json:"password" verify:"true" msg:"redis server password required"` PoolSize uint8 `json:"pool_size" verify:"true" msg:"redis connect pool size required"` // contains filtered or unexported fields }
RDSOption is Redis storage config parameter option.
type RamStore ¶
type RamStore struct {
// contains filtered or unexported fields
}
RamStore Local memory storage.
type RdsStore ¶
type RdsStore struct {
// contains filtered or unexported fields
}
RdsStore remote redis server storage.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is web session struct
func GetSession ¶
GetSession Get session data from the Request
func Migrate ¶
func Migrate(write http.ResponseWriter, old *Session) (*Session, error)
Migrate migrate old session data to new session
type Storage ¶
type Storage interface { // Read data from store Read(s *Session) (err error) // Write data to storage Write(s *Session) (err error) // Remove data from storage Remove(s *Session) (err error) }
Storage global session data store interface. You can customize the storage medium by implementing this interface.
Click to show internal directories.
Click to hide internal directories.