boltstore

package module
v0.0.0-...-4a15812 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 7 Imported by: 1

README

boltstore

Gorilla's Session store implementation with BoltDB

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidId = errors.New("boltstore: invalid session id")

Functions

This section is empty.

Types

type Session

type Session struct {
	ID       string `boltholdKey:"ID"`
	Data     string
	Modified time.Time `boltholdIndex:"Modified"`
}

Session object store in BoltDB

type Store

type Store struct {
	Codecs  []securecookie.Codec
	Options *sessions.Options
	// contains filtered or unexported fields
}

BoltStore stores sessions in BoltDB

func New

func New(s *bolthold.Store, maxAge int, keyPairs ...[]byte) *Store

NewBoltStore returns a new BoltStore.

func (*Store) Get

func (m *Store) Get(r *http.Request, name string) (
	*sessions.Session, error,
)

Get registers and returns a session for the given name and session store. It returns a new session if there are no sessions registered for the name.

func (*Store) MaxAge

func (m *Store) MaxAge(age int)

MaxAge sets the maximum age for the store and the underlying cookie implementation. Individual sessions can be deleted by setting Options.MaxAge = -1 for that session.

func (*Store) New

func (m *Store) New(r *http.Request, name string) (
	*sessions.Session, error,
)

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

func (*Store) Save

func (m *Store) Save(_ *http.Request, w http.ResponseWriter,
	session *sessions.Session,
) error

Save saves all sessions registered for the current request.

Jump to

Keyboard shortcuts

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