Documentation
¶
Index ¶
- func NewDefaultSession() (*defaultSession, error)
- type RequestSession
- type RequestSessions
- type Session
- type SessionInfo
- func (t *SessionInfo) ClearCache(request *http.Request)
- func (t *SessionInfo) GetHandler(c http.Handler) http.Handler
- func (t *SessionInfo) GetSession(request *http.Request) (Session, error)
- func (t *SessionInfo) GetSessionID(request *http.Request) (string, error)
- func (t *SessionInfo) PersistSession(request *http.Request) error
- func (t *SessionInfo) SaveSession(w http.ResponseWriter, r *http.Request)
- func (t *SessionInfo) SetSession(request *http.Request, s Session)
- func (t *SessionInfo) SetSessionCookie(response http.ResponseWriter, s Session) error
- type SessionStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDefaultSession ¶
func NewDefaultSession() (*defaultSession, error)
Types ¶
type RequestSession ¶
type RequestSessions ¶
type RequestSessions struct {
RequestSessions []RequestSession
}
func (*RequestSessions) Delete ¶
func (t *RequestSessions) Delete(request *http.Request)
func (*RequestSessions) Get ¶
func (t *RequestSessions) Get(request *http.Request) RequestSession
func (*RequestSessions) Set ¶
func (t *RequestSessions) Set(s RequestSession)
type Session ¶
type Session interface {
// This returns the Session ID that can/will be stored in the clients cookie.
// Even if the session is new a session id should be returned.
ID() (string, error)
// The Expiry time when the session times out.
Expiry() time.Time
// Set when the session timeout.
SetExpiry(time.Time)
// Set Session Object
Set(key, object interface{}) error
// Get Session Object
Get(key interface{}) (interface{}, error)
// Delete Session Object
// We Shouldn't error if the session object no longer exists.
Delete(key interface{}) error
// Keys returns all the keys within the session.
Keys() ([]interface{}, error)
// Purge
// Remove all values assigned with the sesion.
Purge() error
// Support Writing to Disc(k?)
GobDecode([]byte) error
// If you've got to write it you've got to read it.
GobEncode() ([]byte, error)
}
type SessionInfo ¶
type SessionInfo struct {
Cookie struct {
Name string
Path string
Domain string
}
Timeout time.Duration
Store SessionStore
Cache RequestSessions
}
func (*SessionInfo) ClearCache ¶
func (t *SessionInfo) ClearCache(request *http.Request)
Clear the Request From the Active Cache. This should always be done when getsession has been called.
func (*SessionInfo) GetHandler ¶
func (t *SessionInfo) GetHandler(c http.Handler) http.Handler
Wrapper function to allow http.handler chaining.
func (*SessionInfo) GetSession ¶
func (t *SessionInfo) GetSession(request *http.Request) (Session, error)
Get The session, try from cache then fallback to store.
func (*SessionInfo) GetSessionID ¶
func (t *SessionInfo) GetSessionID(request *http.Request) (string, error)
Get the Session Id From the current Request.
func (*SessionInfo) PersistSession ¶
func (t *SessionInfo) PersistSession(request *http.Request) error
Persist session to underlying store.
func (*SessionInfo) SaveSession ¶
func (t *SessionInfo) SaveSession(w http.ResponseWriter, r *http.Request)
func (*SessionInfo) SetSession ¶
func (t *SessionInfo) SetSession(request *http.Request, s Session)
Set Session in the Request Cache.
func (*SessionInfo) SetSessionCookie ¶
func (t *SessionInfo) SetSessionCookie(response http.ResponseWriter, s Session) error
Try and Set the session id in the browsers cookie.
type SessionStore ¶
type SessionStore interface {
// Get A Session Based on this ID
// If no Session can be found a new empty session should be created.
Get(id string) (Session, error)
// Save the current session to the store.
Set(s Session) error
// Delete the Session
Delete(id string) error
// All, list all sessions in the store.
All() ([]Session, error)
}
Click to show internal directories.
Click to hide internal directories.