sessions

package
v0.0.0-...-e22b688 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2019 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultKey = "github.com/gin-contrib/sessions"
)

Variables

This section is empty.

Functions

func Sessions

func Sessions(name string, store sessions.Store) gin.HandlerFunc

func SessionsMany

func SessionsMany(names []string, store sessions.Store) gin.HandlerFunc

Types

type MockSession

type MockSession struct {
	mock.Mock
}

func (*MockSession) AddFlash

func (_m *MockSession) AddFlash(value interface{}, vars ...string)

func (*MockSession) Clear

func (_m *MockSession) Clear()

func (*MockSession) Delete

func (_m *MockSession) Delete(key interface{})

func (*MockSession) Flashes

func (_m *MockSession) Flashes(vars ...string) []interface{}

func (*MockSession) Get

func (_m *MockSession) Get(key interface{}) interface{}

func (*MockSession) Options

func (_m *MockSession) Options(*sessions.Options)

func (*MockSession) Save

func (_m *MockSession) Save() error

func (*MockSession) Session

func (_m *MockSession) Session() *sessions.Session

func (*MockSession) Set

func (_m *MockSession) Set(key interface{}, val interface{})

type Session

type Session interface {
	// Get returns the session value associated to the given key.
	Get(key interface{}) interface{}
	// Set sets the session value associated to the given key.
	Set(key interface{}, val interface{})
	// Delete removes the session value associated to the given key.
	Delete(key interface{})
	// Clear deletes all values in the session.
	Clear()
	// AddFlash adds a flash message to the session.
	// A single variadic argument is accepted, and it is optional: it defines the flash key.
	// If not defined "_flash" is used by default.
	AddFlash(value interface{}, vars ...string)
	// Flashes returns a slice of flash messages from the session.
	// A single variadic argument is accepted, and it is optional: it defines the flash key.
	// If not defined "_flash" is used by default.
	Flashes(vars ...string) []interface{}
	// Options sets configuration for a session.
	Options(*sessions.Options)
	// Save saves all sessions used during the current request.
	Save() error
	Session() *sessions.Session
}

func Default

func Default(c *gin.Context) Session

shortcut to get session

func DefaultMany

func DefaultMany(c *gin.Context, name string) Session

shortcut to get session with given name

Jump to

Keyboard shortcuts

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