Documentation ¶
Index ¶
- func Middleware(opts ...OptionFunc) gin.HandlerFunc
- type CookieStore
- type Option
- type OptionFunc
- func SetAlwaysRefresh(ok bool) OptionFunc
- func SetCookieDomain(domain string) OptionFunc
- func SetCookieHttpOnly(yes bool) OptionFunc
- func SetCookieName(name string) OptionFunc
- func SetCookiePath(path string) OptionFunc
- func SetExpriedTime(dur time.Duration) OptionFunc
- func SetStore(store Store) OptionFunc
- type RedisStore
- type Session
- func (sess *Session) DefaultBool(key string, def bool) bool
- func (sess *Session) DefaultDuration(key string, def time.Duration) time.Duration
- func (sess *Session) DefaultFloat32(key string, def float32) float32
- func (sess *Session) DefaultFloat64(key string, def float64) float64
- func (sess *Session) DefaultInt(key string, def int) int
- func (sess *Session) DefaultIntSlice(key string, def []int) []int
- func (sess *Session) DefaultString(key string, def string) string
- func (sess *Session) DefaultStringMap(key string, def map[string]interface{}) map[string]interface{}
- func (sess *Session) DefaultStringMapString(key string, def map[string]string) map[string]string
- func (sess *Session) DefaultStringSlice(key string, def []string) []string
- func (sess *Session) DefaultTime(key string, def time.Time) time.Time
- func (sess *Session) Get(key string) (interface{}, bool)
- func (sess *Session) GetBool(key string) (bool, bool)
- func (sess *Session) GetDuration(key string) (time.Duration, bool)
- func (sess *Session) GetFloat32(key string) (float32, bool)
- func (sess *Session) GetFloat64(key string) (float64, bool)
- func (sess *Session) GetInt(key string) (int, bool)
- func (sess *Session) GetIntSlice(key string) ([]int, bool)
- func (sess *Session) GetString(key string) (string, bool)
- func (sess *Session) GetStringMap(key string) (map[string]interface{}, bool)
- func (sess *Session) GetStringMapString(key string) (map[string]string, bool)
- func (sess *Session) GetStringSlice(key string) ([]string, bool)
- func (sess *Session) GetTime(key string) (time.Time, bool)
- func (sess *Session) IsSet(key string) bool
- func (sess *Session) Load() error
- func (sess *Session) MustBool(key string) bool
- func (sess *Session) MustDuration(key string) time.Duration
- func (sess *Session) MustFloat32(key string) float32
- func (sess *Session) MustFloat64(key string) float64
- func (sess *Session) MustInt(key string) int
- func (sess *Session) MustIntSlice(key string) []int
- func (sess *Session) MustString(key string) string
- func (sess *Session) MustStringMap(key string) map[string]interface{}
- func (sess *Session) MustStringMapString(key string) map[string]string
- func (sess *Session) MustStringSlice(key string) []string
- func (sess *Session) MustTime(key string) time.Time
- func (sess *Session) Save() error
- func (sess *Session) Set(key string, val interface{})
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CookieStore ¶
type CookieStore struct { }
CookieStore a store use cookies
func (*CookieStore) Load ¶ added in v1.0.2
func (s *CookieStore) Load(sess *Session) error
Load load data from cookie.
func (*CookieStore) Save ¶ added in v1.0.2
func (s *CookieStore) Save(sess *Session) error
Save save change to cookie.
type OptionFunc ¶
type OptionFunc func(*Option)
OptionFunc .
func SetAlwaysRefresh ¶
func SetAlwaysRefresh(ok bool) OptionFunc
func SetCookieDomain ¶ added in v1.0.2
func SetCookieDomain(domain string) OptionFunc
SetCookieDomain .
func SetCookieHttpOnly ¶ added in v1.0.2
func SetCookieHttpOnly(yes bool) OptionFunc
SetCookieHttpOnly .
func SetExpriedTime ¶
func SetExpriedTime(dur time.Duration) OptionFunc
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore a store use cookies
func (*RedisStore) Load ¶ added in v1.0.2
func (s *RedisStore) Load(sess *Session) error
Load load data from redis.
func (*RedisStore) Save ¶ added in v1.0.2
func (s *RedisStore) Save(sess *Session) error
Save save change to redis.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func GetSession ¶
GetSession get session from gin context
func Must ¶ added in v1.0.2
Must get session before GetSession function. Panic occurs when session instance is not found.
func (*Session) DefaultBool ¶
DefaultBool get value by key. if not exists well be returns default value.
func (*Session) DefaultDuration ¶ added in v1.0.2
DefaultDuration get value by key. if not exists well be returns default value.
func (*Session) DefaultFloat32 ¶
DefaultFloat32 get value by key. if not exists well be returns default value.
func (*Session) DefaultFloat64 ¶
DefaultFloat64 get value by key. if not exists well be returns default value.
func (*Session) DefaultInt ¶
DefaultInt get value by key. if not exists well be returns default value.
func (*Session) DefaultIntSlice ¶
DefaultIntSlice get value by key. if not exists well be returns default value.
func (*Session) DefaultString ¶
DefaultString get value by key. if not exists well be returns default value.
func (*Session) DefaultStringMap ¶ added in v1.0.2
func (sess *Session) DefaultStringMap(key string, def map[string]interface{}) map[string]interface{}
DefaultStringMap get value by key. if not exists well be returns default value.
func (*Session) DefaultStringMapString ¶ added in v1.0.2
DefaultStringMapString get value by key. if not exists well be returns default value.
func (*Session) DefaultStringSlice ¶ added in v1.0.2
DefaultStringSlice get value by key. if not exists well be returns default value.
func (*Session) DefaultTime ¶ added in v1.0.2
DefaultTime get value by key. if not exists well be returns default value.
func (*Session) GetDuration ¶ added in v1.0.2
GetDuration get value and exists
func (*Session) GetFloat32 ¶
GetFloat32 get value and exists
func (*Session) GetFloat64 ¶
GetFloat64 get value and exists
func (*Session) GetIntSlice ¶
GetIntSlice get value and exists
func (*Session) GetStringMap ¶ added in v1.0.2
GetStringMap get value and exists
func (*Session) GetStringMapString ¶ added in v1.0.2
GetStringMapString get value and exists
func (*Session) GetStringSlice ¶ added in v1.0.2
GetStringSlice get value and exists
func (*Session) MustBool ¶ added in v1.0.2
MustBool get value by key. if exists well be returns value, if not exists well return false.
func (*Session) MustDuration ¶ added in v1.0.2
MustDuration get value by key.
func (*Session) MustFloat32 ¶ added in v1.0.2
MustFloat32 get value by key. if exists well be returns value, if not exists well return false.
func (*Session) MustFloat64 ¶ added in v1.0.2
MustFloat64 get value by key. if exists well be returns value, if not exists well return false.
func (*Session) MustInt ¶ added in v1.0.2
MustInt get value by key. if exists well be returns value, if not exists well return false.
func (*Session) MustIntSlice ¶ added in v1.0.2
MustIntSlice get value by key.
func (*Session) MustString ¶ added in v1.0.2
MustString get value by key. if exists well be returns string value, if not exists well return empty string.
func (*Session) MustStringMap ¶ added in v1.0.2
MustStringMap get value by key.
func (*Session) MustStringMapString ¶ added in v1.0.2
MustStringMapString get value by key.
func (*Session) MustStringSlice ¶ added in v1.0.2
MustStringSlice get value by key.
type Store ¶
Store .
func NewCookieStore ¶ added in v1.0.2
func NewCookieStore() Store
NewCookieStore create a store with redis instance.
func NewRedisStore ¶
func NewRedisStore(client *redis.Client) Store
NewRedisStore create a store with redis instance.