redstore

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{Skipper: middleware.DefaultSkipper}

Functions

func Get

func Get(name string, c echo.Context) (*sessions.Session, error)

func Middleware

func Middleware(store sessions.Store) echo.MiddlewareFunc

func MiddlewareWithConfig

func MiddlewareWithConfig(config Config) echo.MiddlewareFunc

func New

func New(name string, c echo.Context) (*sessions.Session, error)

Types

type Config

type Config struct {
	Skipper middleware.Skipper
	Store   sessions.Store
}

type GobSerializer

type GobSerializer struct{}

GobSerializer ...

func (GobSerializer) Deserialize

func (gs GobSerializer) Deserialize(d []byte, s *sessions.Session) error

func (GobSerializer) Serialize

func (gs GobSerializer) Serialize(s *sessions.Session) ([]byte, error)

type KeyGenFunc

type KeyGenFunc func() (string, error)

type RedisStore

type RedisStore struct {
	// contains filtered or unexported fields
}

RedisStore stores gorilla sessions in Redis

func NewRedisStore

func NewRedisStore(ctx context.Context, client redis.UniversalClient) (*RedisStore, error)

NewRedisStore returns a new RedisStore with default configuration

func (*RedisStore) Close

func (s *RedisStore) Close() error

Close closes the Redis store

func (*RedisStore) Get

func (s *RedisStore) Get(r *http.Request, name string) (*sessions.Session, error)

Get returns a session for the given name after adding it to the registry.

func (*RedisStore) KeyGen

func (s *RedisStore) KeyGen(f KeyGenFunc)

KeyGen sets the key generator function

func (*RedisStore) KeyPrefix

func (s *RedisStore) KeyPrefix(keyPrefix string)

KeyPrefix sets the key prefix to store session in Redis

func (*RedisStore) New

func (s *RedisStore) New(r *http.Request, name string) (*sessions.Session, error)

New returns a session for the given name without adding it to the registry. nolint: errorlint

func (*RedisStore) Options

func (s *RedisStore) Options(opts sessions.Options)

Options set options to use when a new session is created

func (*RedisStore) Save

func (s *RedisStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error

Save adds a single session to the response.

func (*RedisStore) Serializer

func (s *RedisStore) Serializer(ss SessionSerializer)

Serializer sets the session serializer to store session

type SessionSerializer

type SessionSerializer interface {
	Serialize(s *sessions.Session) ([]byte, error)
	Deserialize(b []byte, s *sessions.Session) error
}

SessionSerializer provides an interface for serialize/deserialize a session

Jump to

Keyboard shortcuts

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