Documentation ¶
Index ¶
- type CookieStore
- type GobSerializer
- type RedisStore
- func (s *RedisStore) Close() error
- func (s *RedisStore) Get(r *http.Request, name string) (*gorsessions.Session, error)
- func (s *RedisStore) KeyPrefix() string
- func (s *RedisStore) New(r *http.Request, name string) (*gorsessions.Session, error)
- func (s *RedisStore) Options(options ginsessions.Options)
- func (s *RedisStore) Save(r *http.Request, w http.ResponseWriter, session *gorsessions.Session) error
- func (s *RedisStore) SetKeyPrefix(p string)
- type SessionSerializer
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CookieStore ¶
type CookieStore struct {
*gorsessions.CookieStore
}
CookieStore stores sessions in the browser cookie.
func (*CookieStore) KeyPrefix ¶
func (s *CookieStore) KeyPrefix() string
KeyPrefix doesn't do anything for cookie store.
func (*CookieStore) Options ¶
func (s *CookieStore) Options(options ginsessions.Options)
Options defines how the session cookie should be configured.
func (*CookieStore) SetKeyPrefix ¶
func (s *CookieStore) SetKeyPrefix(p string)
SetKeyPrefix doesn't do anything for cookie store.
type GobSerializer ¶
type GobSerializer struct{}
GobSerializer uses gob package to encode the session map.
func (GobSerializer) Deserialize ¶
func (s GobSerializer) Deserialize(d []byte, ss *gorsessions.Session) error
Deserialize uses gob package to decode the session map.
func (GobSerializer) Serialize ¶
func (s GobSerializer) Serialize(ss *gorsessions.Session) ([]byte, error)
Serialize using gob
type RedisStore ¶
type RedisStore struct { Codecs []securecookie.Codec CookieOptions *gorsessions.Options // default configuration DefaultMaxAge int // default Redis TTL for a MaxAge == 0 session // contains filtered or unexported fields }
RedisStore stores sessions in the redis backend.
func (*RedisStore) Close ¶
func (s *RedisStore) Close() error
Close closes the underlying *redis.Pool.
func (*RedisStore) Get ¶
func (s *RedisStore) Get(r *http.Request, name string) (*gorsessions.Session, error)
Get returns a session for the given name after adding it to the registry.
func (*RedisStore) KeyPrefix ¶
func (s *RedisStore) KeyPrefix() string
KeyPrefix returns the prefix for the redis key.
func (*RedisStore) New ¶
func (s *RedisStore) New(r *http.Request, name string) (*gorsessions.Session, error)
New returns a session for the given name without adding it to the registry.
func (*RedisStore) Options ¶
func (s *RedisStore) Options(options ginsessions.Options)
Options defines how the session cookie should be configured.
func (*RedisStore) Save ¶
func (s *RedisStore) Save(r *http.Request, w http.ResponseWriter, session *gorsessions.Session) error
Save adds a single session to the response.
func (*RedisStore) SetKeyPrefix ¶
func (s *RedisStore) SetKeyPrefix(p string)
SetKeyPrefix sets the prefix for the redis key.
type SessionSerializer ¶
type SessionSerializer interface { Deserialize(d []byte, ss *gorsessions.Session) error Serialize(ss *gorsessions.Session) ([]byte, error) }
SessionSerializer provides an interface hook for alternative serializers.
type Store ¶
type Store interface { ginsessions.Store // SetKeyPrefix returns the prefix for the store key, not available for CookieStore. KeyPrefix() string // SetKeyPrefix sets the prefix for the store key, not available for CookieStore. SetKeyPrefix(p string) }
Store provides an interface to implement various stores.
func NewCookieStore ¶
NewCookieStore initializes a CookieStore.
func NewRedisStore ¶
NewRedisStore initializes a RedisStore instance with connections pool.