sessx

package
v0.0.0-...-fe173bb Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package sessx reads effective parameter values from GET, POST and SESSION. It also reads consolidated request params (GET, POST). Environment variable REDIS_SESSION_STORE switches to redis storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Mgr

func Mgr() *scs.SessionManager

Mgr exposes the session manager

func SessionGet

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

SessionGet - request handler for session diagnosis via http

func SessionPut

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

SessionPut - request handler for session diagnosis via http

Types

type SessT

type SessT struct {
	*scs.SessionManager
	// contains filtered or unexported fields
}

SessT enhances the alexedwards/scs session.

func New

func New(w io.Writer, r *http.Request) *SessT

New returns a new enhanced session variable.

func (*SessT) EffectiveFloat

func (sess *SessT) EffectiveFloat(key string, defaultVal ...float64) (float64, bool, error)

EffectiveFloat is a wrapper around EffectiveStr with subsequent parsing into float

func (*SessT) EffectiveInt

func (sess *SessT) EffectiveInt(key string, defaultVal ...int) (int, bool, error)

EffectiveInt is a wrapper around EffectiveStr with subsequent parsing into an int

func (*SessT) EffectiveIsSet

func (sess *SessT) EffectiveIsSet(key string) bool

EffectiveIsSet checks, whether a key is set. First inside the current request via RequestParamIsSet() Then inside the session.

RequestParamIsSet returns the param value as string. But EffectiveIsSet refers to different types in session: integers, floats or objects.

If ParamPersisterMiddleWare is in action, then a few designated session params are always set.

func (*SessT) EffectiveObj

func (sess *SessT) EffectiveObj(key string) (obj interface{}, ok bool)

EffectiveObj helps to retrieve an compound variable from the session.

func (*SessT) EffectiveStr

func (sess *SessT) EffectiveStr(key string, defaultVal ...string) string

EffectiveStr returns the corresponding value from request or session. It returns the zero value "", regardless whether the key was not set at all, or whether key was set to value "".

func (*SessT) PutObject

func (sess *SessT) PutObject(key string, val interface{})

PutObject stores an object into the session. Almost identical to PutString. val can be pointer or value.

func (*SessT) PutString

func (sess *SessT) PutString(key, val string)

PutString stores a string into the session. Almost identical to PutObject.

func (*SessT) ReqParam

func (sess *SessT) ReqParam(key string, defaultVal ...string) (string, bool)

ReqParam searches for the effective value of the *request*, not in session. First among the POST fields. Not among the URL "path" parameters. Then among the URL GET parameters.

It checks, whether any of the above had the param key set to *empty* string.

Second return value is 'is set'

func (*SessT) ReqURI

func (sess *SessT) ReqURI() string

ReqURI is a template helper. The return value contains app url prefix.

Jump to

Keyboard shortcuts

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