session

package
v0.0.0-...-ae8581d Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Session

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

Session is a struct which wraps a gorilla/sessions CookieStore and implements a few methods used for retrieval and storage of session items.

func NewSession

func NewSession(sessionKey string) *Session

NewSession returns a new session instance, based on a provided key

func (*Session) GetFlashes

func (s *Session) GetFlashes(r *http.Request, w http.ResponseWriter) ([]string, error)

GetFlashes returns all flash messages stored in the session. Note that the way flash messages work they are deleted after being retrieved.

func (*Session) GetUser

func (s *Session) GetUser(r *http.Request) (*models.User, error)

GetUser returns the the User from the session, if present

func (*Session) SaveFlash

func (s *Session) SaveFlash(message string, r *http.Request, w http.ResponseWriter) error

SaveFlash saves a flash message to the session

func (*Session) SaveUser

func (s *Session) SaveUser(u *models.User, r *http.Request, w http.ResponseWriter) error

SaveUser saves a user to the session

type TopicalSession

type TopicalSession interface {
	GetUser(r *http.Request) (*models.User, error)
	SaveUser(u *models.User, r *http.Request, w http.ResponseWriter) error
	SaveFlash(message string, r *http.Request, w http.ResponseWriter) error
	GetFlashes(r *http.Request, w http.ResponseWriter) ([]string, error)
}

TopicalSession implements methods necessary to save and retrieve users/flash messages

Jump to

Keyboard shortcuts

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