sessionstore

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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

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

func NewCookieStore(keyPairs ...[]byte) Store

NewCookieStore initializes a CookieStore.

func NewRedisStore

func NewRedisStore(opts *redis.Options, keyPairs ...[]byte) (Store, error)

NewRedisStore initializes a RedisStore instance with connections pool.

Jump to

Keyboard shortcuts

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