sessions

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package sessions is wrapper around github.com/gorilla/sessions.

Dfferences include:

  • keys and values can only be strings
  • way less exposed API surface

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager is a sessions manager. It wraps a session store to ensure that all callers use the same session name.

func NewManager

func NewManager(store gorillaSessions.Store, name string) *Manager

NewManager creates a new sessions manager

func (*Manager) Flash

func (m *Manager) Flash(r *http.Request, w http.ResponseWriter, category, message string)

Flash is a utility function that gets the session, adds a flash message and saves the session

func (*Manager) Get

func (m *Manager) Get(r *http.Request) (*Session, error)

Get returns the session associated with the given request

type Session

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

Session stores values

func (*Session) Expire

func (s *Session) Expire()

Expire will expire the session

func (*Session) Flash

func (s *Session) Flash(category, message string)

Flash will add a message to a category of flashes

func (*Session) Flashes

func (s *Session) Flashes() map[string][]string

Flashes will return all flashes and removes them from the request

func (*Session) Get

func (s *Session) Get(key string) (string, error)

Get will return the value associated with a key

func (*Session) Keys

func (s *Session) Keys() []string

Keys returns available session keys

func (*Session) Save

func (s *Session) Save(r *http.Request, w http.ResponseWriter) error

Save will save the session

func (*Session) Set

func (s *Session) Set(key string, value string)

Set will set the value of a key

Jump to

Keyboard shortcuts

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