session

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyPairs

type KeyPairs []string

func (KeyPairs) ToKeys

func (k KeyPairs) ToKeys() [][]byte

type Model

type Model struct {
	bun.BaseModel `bun:"table:sessions,alias:s"`

	ID        string `bun:",pk,unique"`
	Data      string
	CreatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	ExpiresAt time.Time
}

type Options

type Options struct {
	TableName       string
	SkipCreateTable bool
}

Options for bunstore.

type Store

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

Store represent a bunstore.

func New

func New(db *bun.DB, keyPairs KeyPairs) (*Store, error)

New creates a new bunstore session.

func NewOptions

func NewOptions(db *bun.DB, opts Options, keyPairs KeyPairs) (*Store, error)

NewOptions creates a new bunstore session with options.

func (*Store) Cleanup

func (st *Store) Cleanup()

Cleanup deletes expired sessions.

func (*Store) Get

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

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

func (*Store) MaxAge

func (st *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) MaxLength

func (st *Store) MaxLength(l int)

MaxLength restricts the maximum length of new sessions to l. If l is 0 there is no limit to the size of a session, use with caution. The default is 4096 (default for securecookie).

func (*Store) New

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

New creates a session with name without adding it to the registry.

func (*Store) PeriodicCleanup

func (st *Store) PeriodicCleanup(interval time.Duration, quit <-chan struct{})

PeriodicCleanup runs Cleanup every interval. Close quit channel to stop.

func (*Store) Save

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

Save session and set cookie header.

Jump to

Keyboard shortcuts

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