Documentation
¶
Overview ¶
Package httpsession is a http server session implement for Go.
Installation ¶
Make sure you have installed Go 1.1+ and then:
go get github.com/coscms/xweb/httpsession
More usage, please visit https://github.com/coscms/xweb/httpsession/
Index ¶
- Constants
- Variables
- func GenRandKey(strength int) []byte
- type AfterCreatedListener
- type BeforeReleaseListener
- type CookieTransfer
- type CookieUrlTransfer
- type Id
- type IdGenerator
- type Manager
- func (manager *Manager) AddListener(listener interface{}) error
- func (manager *Manager) Invalidate(rw http.ResponseWriter, session *Session)
- func (manager *Manager) RemoveListener(listener interface{}) error
- func (manager *Manager) Run() error
- func (manager *Manager) Session(req *http.Request, rw http.ResponseWriter) *Session
- func (manager *Manager) SetMaxAge(maxAge time.Duration)
- type MemcacheStore
- func (store *MemcacheStore) Add(id Id)
- func (store *MemcacheStore) Clear(id Id) bool
- func (store *MemcacheStore) Del(id Id, key string) bool
- func (store *MemcacheStore) Exist(id Id) bool
- func (store *MemcacheStore) Get(id Id, key string) interface{}
- func (store *MemcacheStore) Run() error
- func (store *MemcacheStore) Set(id Id, key string, value interface{})
- func (store *MemcacheStore) SetMaxAge(maxAge time.Duration)
- type MemoryStore
- func (store *MemoryStore) Add(id Id)
- func (store *MemoryStore) Clear(id Id) bool
- func (store *MemoryStore) Del(id Id, key string) bool
- func (store *MemoryStore) Exist(id Id) bool
- func (store *MemoryStore) GC()
- func (store *MemoryStore) Get(id Id, key string) interface{}
- func (store *MemoryStore) Run() error
- func (store *MemoryStore) Set(id Id, key string, value interface{})
- func (store *MemoryStore) SetMaxAge(maxAge time.Duration)
- type Session
- func (session *Session) Del(key string) bool
- func (session *Session) Get(key string) interface{}
- func (session *Session) Id() Id
- func (session *Session) Invalidate(rw http.ResponseWriter)
- func (session *Session) IsValid() bool
- func (session *Session) Set(key string, value interface{})
- func (session *Session) SetId(id Id)
- func (session *Session) SetMaxAge(maxAge time.Duration)
- type Sha1Generator
- type Store
- type Transfer
Constants ¶
View Source
const (
DefaultMaxAge = 30 * time.Minute
)
Variables ¶
View Source
var RegNodeToGob bool
Functions ¶
func GenRandKey ¶
Types ¶
type AfterCreatedListener ¶
type AfterCreatedListener interface {
OnAfterCreated(*Session)
}
type BeforeReleaseListener ¶
type BeforeReleaseListener interface {
OnBeforeRelease(*Session)
}
type CookieTransfer ¶
type CookieTransfer struct { Name string MaxAge time.Duration Lock sync.Mutex Secure bool RootPath string Domain string }
CookieRetriever provide sessionid from cookie
func NewCookieTransfer ¶
func (*CookieTransfer) Clear ¶
func (transfer *CookieTransfer) Clear(rw http.ResponseWriter)
func (*CookieTransfer) Set ¶
func (transfer *CookieTransfer) Set(req *http.Request, rw http.ResponseWriter, id Id)
func (*CookieTransfer) SetMaxAge ¶
func (transfer *CookieTransfer) SetMaxAge(maxAge time.Duration)
type CookieUrlTransfer ¶
type CookieUrlTransfer struct {
CookieTransfer
}
func NewCookieUrlTransfer ¶
func NewCookieUrlTransfer(name string, maxAge time.Duration, secure bool, rootPath string) *CookieUrlTransfer
for SWFUpload ...
type Manager ¶
type Manager struct { Path string // contains filtered or unexported fields }
func NewManager ¶
func NewManager(store Store, gen IdGenerator, transfer Transfer) *Manager
func (*Manager) AddListener ¶
func (*Manager) Invalidate ¶
func (manager *Manager) Invalidate(rw http.ResponseWriter, session *Session)
func (*Manager) RemoveListener ¶
type MemcacheStore ¶
type MemcacheStore struct { Debug bool // contains filtered or unexported fields }
func NewMemcacheStore ¶
func NewMemcacheStore(maxAge time.Duration, conn []string) *MemcacheStore
func (*MemcacheStore) Add ¶
func (store *MemcacheStore) Add(id Id)
func (*MemcacheStore) Clear ¶
func (store *MemcacheStore) Clear(id Id) bool
func (*MemcacheStore) Exist ¶
func (store *MemcacheStore) Exist(id Id) bool
func (*MemcacheStore) Get ¶
func (store *MemcacheStore) Get(id Id, key string) interface{}
func (*MemcacheStore) Run ¶
func (store *MemcacheStore) Run() error
func (*MemcacheStore) Set ¶
func (store *MemcacheStore) Set(id Id, key string, value interface{})
func (*MemcacheStore) SetMaxAge ¶
func (store *MemcacheStore) SetMaxAge(maxAge time.Duration)
type MemoryStore ¶
func NewMemoryStore ¶
func NewMemoryStore(maxAge time.Duration) *MemoryStore
func (*MemoryStore) Add ¶
func (store *MemoryStore) Add(id Id)
func (*MemoryStore) Clear ¶
func (store *MemoryStore) Clear(id Id) bool
func (*MemoryStore) Exist ¶
func (store *MemoryStore) Exist(id Id) bool
func (*MemoryStore) Get ¶
func (store *MemoryStore) Get(id Id, key string) interface{}
func (*MemoryStore) Run ¶
func (store *MemoryStore) Run() error
func (*MemoryStore) Set ¶
func (store *MemoryStore) Set(id Id, key string, value interface{})
func (*MemoryStore) SetMaxAge ¶
func (store *MemoryStore) SetMaxAge(maxAge time.Duration)
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func (*Session) Invalidate ¶
func (session *Session) Invalidate(rw http.ResponseWriter)
type Sha1Generator ¶
type Sha1Generator struct {
// contains filtered or unexported fields
}
func NewSha1Generator ¶
func NewSha1Generator(hashKey string) *Sha1Generator
func (*Sha1Generator) IsValid ¶
func (gen *Sha1Generator) IsValid(id Id) bool
Source Files
¶
Click to show internal directories.
Click to hide internal directories.