Documentation ¶
Index ¶
- Constants
- type GobSerializer
- type JSONSerializer
- type KeyGenFunc
- type OptionsFunc
- type Serializer
- type ValkeyStore
- func (s *ValkeyStore) Close()
- func (s *ValkeyStore) Get(r *http.Request, name string) (*sessions.Session, error)
- func (s *ValkeyStore) KeyGen(keyGen KeyGenFunc)
- func (s *ValkeyStore) KeyPrefix(keyPrefix string)
- func (s *ValkeyStore) New(r *http.Request, name string) (*sessions.Session, error)
- func (s *ValkeyStore) Options(options sessions.Options)
- func (s *ValkeyStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
- func (s *ValkeyStore) Serializer(ss Serializer)
Constants ¶
const DefaultKeyPrefix = "session:"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GobSerializer ¶
type GobSerializer struct{}
GobSerializer is a Serializer that uses gob encoding
func NewGobSerializer ¶
func NewGobSerializer() *GobSerializer
NewGobSerializer creates a new GobSerializer
func (*GobSerializer) Deserialize ¶
func (s *GobSerializer) Deserialize(b []byte, session *sessions.Session) error
Deserialize deserializes a session using gob encoding
type JSONSerializer ¶
type JSONSerializer struct{}
JSONSerializer is a Serializer that uses JSON encoding
func NewJSONSerializer ¶
func NewJSONSerializer() *JSONSerializer
NewJSONSerializer creates a new JSONSerializer
func (*JSONSerializer) Deserialize ¶
func (s *JSONSerializer) Deserialize(b []byte, session *sessions.Session) error
Deserialize deserializes a session using JSON encoding
type KeyGenFunc ¶
KeyGenFunc is a function that generates a new session key
type OptionsFunc ¶
type OptionsFunc = func(*ValkeyStore)
OptionsFunc is a function that sets options on a ValkeyStore
func WithKeyGenFunc ¶
func WithKeyGenFunc(kg KeyGenFunc) OptionsFunc
WithKeyGenFunc sets the key generation function for a ValkeyStore
func WithKeyPrefix ¶
func WithKeyPrefix(p string) OptionsFunc
WithKeyPrefix sets the key prefix for a ValkeyStore
func WithSerializer ¶
func WithSerializer(s Serializer) OptionsFunc
WithSerializer sets the serializer for a ValkeyStore
func WithSessionOptions ¶
func WithSessionOptions(options sessions.Options) OptionsFunc
WithSessionOptions sets the default session options for a ValkeyStore
type Serializer ¶
type Serializer interface { Serialize(s *sessions.Session) ([]byte, error) Deserialize(b []byte, s *sessions.Session) error }
Serializer is an interface for serializing and deserializing sessions for Valkey
type ValkeyStore ¶
type ValkeyStore struct {
// contains filtered or unexported fields
}
ValkeyStore stores gorilla sessions in Valkey
func NewValkeyStore ¶
func NewValkeyStore(client valkey.Client, options ...OptionsFunc) (*ValkeyStore, error)
NewValkeyStore creates a new ValkeyStore with the given client and options.
func (*ValkeyStore) KeyGen ¶
func (s *ValkeyStore) KeyGen(keyGen KeyGenFunc)
KeyGen sets the key generator for the store.
func (*ValkeyStore) KeyPrefix ¶
func (s *ValkeyStore) KeyPrefix(keyPrefix string)
KeyPrefix sets the key prefix for the store.
func (*ValkeyStore) New ¶
New returns a new session with the given name without adding it to the registry.
func (*ValkeyStore) Options ¶
func (s *ValkeyStore) Options(options sessions.Options)
Options sets the default session options for the store.
func (*ValkeyStore) Save ¶
func (s *ValkeyStore) Save(r *http.Request, w http.ResponseWriter, session *sessions.Session) error
Save adds a single session to the response.
If the Options.MaxAge of the session is <= 0 then the session file will be deleted from the store. With this process it enforces the properly session cookie handling so no need to trust in the cookie management in the web browser.
func (*ValkeyStore) Serializer ¶
func (s *ValkeyStore) Serializer(ss Serializer)
Serializer sets the serializer for the store.