Documentation ¶
Index ¶
- func Clear(ctx context.Context)
- func ClearStack(ctx context.Context, stack string)
- func Get(ctx context.Context, key string) (v interface{})
- func GetBool(ctx context.Context, key string) (v bool)
- func GetFloat32(ctx context.Context, key string) (v float32)
- func GetFloat64(ctx context.Context, key string) (v float64)
- func GetInt(ctx context.Context, key string) (v int)
- func GetString(ctx context.Context, key string) (v string)
- func Has(ctx context.Context, key string) bool
- func HasSession(ctx context.Context) bool
- func PopStack(ctx context.Context, stack string) (value string)
- func PushStack(ctx context.Context, stack string, value string)
- func Remove(ctx context.Context, key string)
- func Reset(ctx context.Context)
- func Set(ctx context.Context, key string, v interface{})
- func SetBool(ctx context.Context, key string, v bool)
- func SetFloat32(ctx context.Context, key string, v float32)
- func SetFloat64(ctx context.Context, key string, v float64)
- func SetInt(ctx context.Context, key string, v int)
- func SetSessionManager(m ManagerI)
- func SetString(ctx context.Context, key string, v string)
- func Use(next http.Handler) http.Handler
- type ManagerI
- type Mock
- type ScsManager
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clear ¶
Clear removes all of the values from the session store. It does not remove the session token itself (the Cookie for example). To remove the token also, call Reset() in addition to Clear()
func ClearStack ¶ added in v0.0.3
ClearStack clears the named stack
func Get ¶
Get returns an interface value stored at the given key. nil is returned if nothing is there.
func GetBool ¶
GetBool returns the boolean at the given key in the session store. If the key does not exist OR if what does exist at that key is not a boolean, false will be returned.
func GetFloat32 ¶ added in v0.9.3
GetFloat32 returns the float32 at the given key in the session store. If the key does not exist OR if what does exist at that key is not a float, 0 will be returned.
func GetFloat64 ¶ added in v0.9.3
GetFloat64 returns the float64 at the given key in the session store. If the key does not exist OR if what does exist at that key is not a float, 0 will be returned.
func GetInt ¶
GetInt returns the integer at the given key in the session store. If the key does not exist OR if what does exists at that key is not an integer, zero will be returned. Call Has() if the zero value has meaning for you and you want to check for existence.
func GetString ¶
GetString returns the string at the given key in the session store. If the key does not exist OR if what does exist at that key is not a string, an empty string will be returned.
func HasSession ¶ added in v0.27.6
HasSession returns true if the session exists.
func PopStack ¶ added in v0.0.3
PopStack pops the given value off of the named stack and returns it.
func PushStack ¶ added in v0.0.3
PushStack pushes the given value onto the given named stack in the session. The name becomes a variable in the current session. The value must be JsonSerializable.
func Reset ¶
Reset will destroy the old session token. If you also call Clear, or don't have any session data after processing the request, it will remove the session token all together after the request. If you do have session data, this will cause the session data to be moved to a new session token.
func SetFloat32 ¶ added in v0.9.3
SetFloat32 will put the float32 value at the given key in the session store.
func SetFloat64 ¶ added in v0.9.3
SetFloat64 will put the float64 value at the given key in the session store.
func SetSessionManager ¶
func SetSessionManager(m ManagerI)
SetSessionManager injects the given session manager as the global session manager
func Use ¶
Use injects the session manager into the page management process. It adds to the context in the Request object so that later session requests can get to the session information, and also wraps the given handler in pre and post processing functions. It should be called from your middleware processing stack.
Types ¶
type ManagerI ¶
ManagerI is the interface for session managers.
func NewScsManager ¶ added in v0.0.3
func NewScsManager(mgr *scs.SessionManager) ManagerI
func SessionManager ¶ added in v0.13.8
func SessionManager() ManagerI
type ScsManager ¶ added in v0.0.3
type ScsManager struct {
*scs.SessionManager
}
ScsManager implements the ManagerI interface for the github.com/alexedwards/scs session manager.
Note that this manager does post-processing on the response writer, including writing headers. It therefore relies on the buffered output handler to collect the output before writing the headers.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is the object that is stored in the context. (Actually a pointer to that object). You normally do not work with the Session object, but instead should call session.GetInt, session.SetInt, etc. Session is exported so that it can be created by custom session managers.
func NewSession ¶
func NewSession() *Session
NewSession creates a new session object for use by session managers. You should not normally need to call this. To reset the session data, call Reset()
func (*Session) MarshalBinary ¶
MarshallBinary serializes the session data for storage.
func (*Session) UnmarshalBinary ¶
UnmarshalBinary unserializes saved session data