session

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2021 License: MIT Imports: 5 Imported by: 1

README

session

Session handler

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Errors

View Source
var (
	ErrSessionNotFound = errors.New("session not found")
)

Errors

Functions

This section is empty.

Types

type Config

type Config struct {
	KeyLength int    `kong:"prefix='session-',default='32',help='Length of session key',hidden=''"`
	Encoding  string `kong:"prefix='session-',default='base64',enum='none,base64',help='Encoding'"`
}

Config values for session management

type Handler

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

Handler is used to handle sessions

func New

func New(options *Options) (*Handler, error)

New instantiates a session generator

func (*Handler) Get added in v0.0.3

func (h *Handler) Get(id string) (*Session, error)

func (*Handler) New

func (h *Handler) New() (*Session, error)

New Creates a new session with a random id

type Options

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

func DefaultOptions

func DefaultOptions(config *Config) *Options

func (*Options) WithDataStore

func (o *Options) WithDataStore(value datastore.Handler) *Options

WithDataStore sets the datastore for the server

func (*Options) WithLogger

func (o *Options) WithLogger(value *zap.Logger) *Options

WithLogger sets the logger for the server

type Session added in v0.0.3

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

func (*Session) Get added in v0.0.3

func (s *Session) Get(key string) (interface{}, error)

func (*Session) Id added in v0.0.3

func (s *Session) Id() string

func (*Session) Set added in v0.0.3

func (s *Session) Set(key string, value interface{}) error

Jump to

Keyboard shortcuts

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