session

package
v0.0.0-...-f46f3e0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(
	cache *cache.Cache,
	handler http.Handler,
) http.Handler

Middleware that inejcts the Session into the request context of the provided handler.

Types

type Session

type Session struct {
	// True if the user is logged in.
	IsUserLoggedIn bool
	// Unique identifier of the logged in user if the user is logged in.
	UserID uint
	// contains filtered or unexported fields
}

Encapsulates the session information encoded within a particular request.

func ExtractFrom

func ExtractFrom(context context.Context) *Session

Extracts the Session embedded within the specified context, panicing if no such embedded Session exists.

func (*Session) LogIn

func (session *Session) LogIn(userID uint) error

Attaches a user to this Session.

func (*Session) LogOut

func (session *Session) LogOut() error

Ends this Session, effectively logging the user out.

Jump to

Keyboard shortcuts

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