Documentation ¶
Overview ¶
simplistic http sessions based on memcache, with in-memory stub for development
Index ¶
- type Manager
- func (m *Manager) MustSession(w http.ResponseWriter, r *http.Request) *Session
- func (m *Manager) MustWriteSession(w http.ResponseWriter, s *Session)
- func (m *Manager) Session(w http.ResponseWriter, r *http.Request) (ret *Session, err error)
- func (m *Manager) WriteSession(w http.ResponseWriter, s *Session) error
- type Session
- type Values
- func (v Values) GetBool(key string) bool
- func (v Values) GetFloat64(key string) float64
- func (v Values) GetInt64(key string) int64
- func (v Values) GetString(key string) string
- func (v Values) SetBool(key string, val bool)
- func (v Values) SetFloat64(key string, val float64)
- func (v Values) SetInt64(key string, val int64)
- func (v Values) SetString(key string, val string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct { TemplateCookie *http.Cookie // this cookie is copied and the value modified for each one written to the client Expiration time.Duration // how long until session expiration - passed back to memcache Client *memcache.Client // the memcache client or nil to mean store in memory (stub for development) MemcacheKeyPrefix string // prefix memcache keys with this // contains filtered or unexported fields }
func NewManager ¶
NewManager returns a new *Manager with sensible defaults. You need to provide the memcache client and an optional prefix for the keys we store in memcache.
func (*Manager) MustSession ¶
func (*Manager) MustWriteSession ¶
func (m *Manager) MustWriteSession(w http.ResponseWriter, s *Session)
func (*Manager) Session ¶
Get or create the session object, sets the appropriate cookie, does not write to the backing store
func (*Manager) WriteSession ¶
func (m *Manager) WriteSession(w http.ResponseWriter, s *Session) error
write the actual session back to he memcache backend
type Session ¶
type Session struct { Key string // the key for this session Cookie *http.Cookie // the cookie we will write to the client Values Values // values of the session }
type Values ¶
type Values map[string]interface{}
func (Values) GetFloat64 ¶
func (Values) SetFloat64 ¶
Click to show internal directories.
Click to hide internal directories.