Documentation ¶
Index ¶
- func Base64Decode(dst *Dict, src []byte) error
- func Base64Encode(src Dict) ([]byte, error)
- func MSGPDecode(dst *Dict, src []byte) error
- func MSGPEncode(src Dict) ([]byte, error)
- type Config
- type Dict
- type Logger
- type Provider
- type Session
- func (s *Session) Destroy(ctx *fasthttp.RequestCtx) error
- func (s *Session) Get(ctx *fasthttp.RequestCtx) (*Store, error)
- func (s *Session) Regenerate(ctx *fasthttp.RequestCtx) error
- func (s *Session) Save(ctx *fasthttp.RequestCtx, store *Store) error
- func (s *Session) SetProvider(provider Provider) error
- type Store
- func (s *Store) Delete(key string)
- func (s *Store) DeleteBytes(key []byte)
- func (s *Store) Flush()
- func (s *Store) Get(key string) interface{}
- func (s *Store) GetAll() Dict
- func (s *Store) GetBytes(key []byte) interface{}
- func (s *Store) GetExpiration() time.Duration
- func (s *Store) GetSessionID() []byte
- func (s *Store) HasExpirationChanged() bool
- func (s *Store) Ptr() *Dict
- func (s *Store) Reset()
- func (s *Store) Set(key string, value interface{})
- func (s *Store) SetBytes(key []byte, value interface{})
- func (s *Store) SetExpiration(expiration time.Duration) error
- func (s *Store) SetSessionID(id []byte)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { // cookie name CookieName string // cookie domain Domain string // If you want to delete the cookie when the browser closes, set it to -1. // // 0 means no expire, (24 years) // -1 means when browser closes // >0 is the time.Duration which the session cookies should expire. Expiration time.Duration // gc life time to execute it GCLifetime time.Duration // set whether to pass this bar cookie only through HTTPS Secure bool // allows you to declare if your cookie should be restricted to a first-party or same-site context. // possible values: lax, strict, none CookieSameSite fasthttp.CookieSameSite // sessionID is in url query SessionIDInURLQuery bool // sessionName in url query SessionNameInURLQuery string // sessionID is in http header SessionIDInHTTPHeader bool // sessionName in http header SessionNameInHTTPHeader string // SessionIDGeneratorFunc should returns a random session id. SessionIDGeneratorFunc func() []byte // IsSecureFunc should return whether the communication channel is secure // in order to set the secure flag to true according to Secure flag. IsSecureFunc func(*fasthttp.RequestCtx) bool // EncodeFunc session value serialize func EncodeFunc func(src Dict) ([]byte, error) // DecodeFunc session value unSerialize func DecodeFunc func(dst *Dict, src []byte) error // Logger Logger Logger // contains filtered or unexported fields }
Config configuration of session manager
func NewDefaultConfig ¶
func NewDefaultConfig() Config
NewDefaultConfig returns a new default configuration
type Logger ¶
type Logger interface { Print(v ...interface{}) Printf(format string, v ...interface{}) }
type Provider ¶
type Provider interface { Get(id []byte) ([]byte, error) Save(id, data []byte, expiration time.Duration) error Destroy(id []byte) error Regenerate(id, newID []byte, expiration time.Duration) error Count() int NeedGC() bool GC() error }
Provider interface implemented by providers
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session manages the users sessions
func (*Session) Destroy ¶
func (s *Session) Destroy(ctx *fasthttp.RequestCtx) error
Destroy destroys the session of the current user
func (*Session) Get ¶
func (s *Session) Get(ctx *fasthttp.RequestCtx) (*Store, error)
Get returns the user session if it does not exist, it will be generated
func (*Session) Regenerate ¶
func (s *Session) Regenerate(ctx *fasthttp.RequestCtx) error
Regenerate generates a new session id to the current user
func (*Session) Save ¶
func (s *Session) Save(ctx *fasthttp.RequestCtx, store *Store) error
Save saves the user session
Warning: Don't use the store after exec this function, because, you will lose the after data For avoid it, defer this function in your request handler
func (*Session) SetProvider ¶
SetProvider sets the session provider used by the sessions manager
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store represents the user session
func (*Store) DeleteBytes ¶
DeleteBytes deletes a value from the given key
func (*Store) GetExpiration ¶
GetExpiration returns the expiration for current session
func (*Store) GetSessionID ¶
GetSessionID returns the session id
func (*Store) HasExpirationChanged ¶
HasExpirationChanged checks wether the expiration has been changed
func (*Store) SetExpiration ¶
SetExpiration sets the expiration for current session
func (*Store) SetSessionID ¶
SetSessionID sets the session id