Documentation
¶
Index ¶
- func AddSessionDeathCallback(fn func(string))
- func Chain(mw ...func(http.Handler) http.Handler) http.Handler
- func Checking(check func(*Session) bool, code int) func(http.Handler) http.Handler
- func LoggedIn(s *Session) bool
- func Logging(next http.Handler) http.Handler
- func Not(fn func(*Session) bool) func(*Session) bool
- func Sessioned(next http.Handler) http.Handler
- func Term(h http.Handler) func(http.Handler) http.Handler
- type Session
- func (s *Session) Del(key string)
- func (s *Session) Get(key string) (interface{}, bool)
- func (s *Session) GetUser() (user int64, valid bool)
- func (s *Session) Invalid() (value bool)
- func (s *Session) Invalidate()
- func (s *Session) Key() string
- func (s *Session) Logout()
- func (s *Session) Persist() bool
- func (s *Session) Put(key string, value interface{})
- func (s *Session) SetUser(value int64)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddSessionDeathCallback ¶
func AddSessionDeathCallback(fn func(string))
AddSessionDeathCallback adds a function to the list of function to be called when a session dies. The key of the session is passed the function to identify the dying session in other data structures.
func Chain ¶
Chain is a bootstrapping mechanism to wrap the results of given middleware constructors around each other to build a fully decorated middleware which chains them all.
func Checking ¶
Checking is a middleware constructor which checks the session with a given test. When the test passed the inner handler is called. Otherwise the chain excecution is terminated with given HTTP code.
func LoggedIn ¶
LoggedIn is a session test function which checks if the session is associated with user.
Types ¶
type Session ¶
Session encapsulates the session state,
func FromContext ¶
FromContext extracts a session from a given context.
func NewSession ¶
NewSession creates a new session with a given key.
func (*Session) Get ¶
Get returns the value associated with the given key. The second return value indicates if the value was found.
func (*Session) GetUser ¶
GetUser returns the ID of the user associated with the session. The second return value is false if there is no user bound to the session.
func (*Session) Logout ¶
func (s *Session) Logout()
Logout does a logout of the session so there is no longer a user attached to it.
func (*Session) Persist ¶
Persist writes the session to the backend or deletes it from the infrastructure if its invalid.