kbsession

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: MIT Imports: 5 Imported by: 1

README

kbsession

Go Reference

A web session management library for Katabole.

For a canonical place these are used see kbexample.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFlash

func AddFlash(r *http.Request, key, value string)

AddFlash adds a flash message to the session for display at the next page render. The key groups together messages of a similar category and will be interpeted by the template. It's common to use keys like "success", "info", "warning", and "error" which map to CSS classes. Value is the string to be displayed.

func Flash

func Flash(r *http.Request) map[string][]string

Flash grabs the flash messages from the session and removes them so they'll only be rendered once.

func Get

func Get(r *http.Request) *sessions.Session

Get returns the session from the request context.

func NewMiddleware

func NewMiddleware(sessionStore sessions.Store) func(http.Handler) http.Handler

NewMiddleware returns middleware that decodes the session from the request and adds it to the request context, guaranteeing it'll be there and making gorilla/sessions easier to work with.

func Save

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

SaveSession saves the final session in the request if it's been accessed (i.e. new or modified).

Types

type Handler

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

func (*Handler) ServeHTTP

func (sh *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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