Documentation ¶
Index ¶
- func All() int
- func Destroy(w http.ResponseWriter, r *http.Request) (string, error)
- func Exist(sid string) bool
- func GetSid(r *http.Request) (string, error)
- func Init()
- func NewContext(ctx context.Context, s *SessionStore) context.Context
- func Stop()
- type Manager
- func (p *Manager) All() int
- func (p *Manager) Destroy(w http.ResponseWriter, r *http.Request) (string, error)
- func (p *Manager) Exist(sid string) bool
- func (p *Manager) Get(sid string) (*SessionStore, error)
- func (p *Manager) GetSid(r *http.Request) (sid string, err error)
- func (p *Manager) Start(w http.ResponseWriter, r *http.Request) (store *SessionStore, err error)
- func (p *Manager) StopGC()
- type Option
- type SessionStore
- func (p *SessionStore) CreatedAt() int64
- func (p *SessionStore) Delete(k string) error
- func (p *SessionStore) Get(k string) string
- func (p *SessionStore) Reset() error
- func (p *SessionStore) Set(k, v string) error
- func (p *SessionStore) Sid() string
- func (p *SessionStore) Update(w http.ResponseWriter) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewContext ¶
func NewContext(ctx context.Context, s *SessionStore) context.Context
ctx := NewContext(req.Context(), p) req = req.WithContext(ctx)
NewContext returns a copy of the parent context and associates it with an sessionStore.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
var (
DefaultSession *Manager
)
func StartSession ¶
func StartSession(cf *config.SessionSection, opts_ ...Option) (*Manager, error)
func (*Manager) Start ¶
func (p *Manager) Start(w http.ResponseWriter, r *http.Request) (store *SessionStore, err error)
SessionStart generate or read the session id from http request. if session id exists, return SessionStore with this id.
type SessionStore ¶
SessionStore mysql session store
func FromContext ¶
func FromContext(ctx context.Context) (s *SessionStore, ok bool)
FromContext returns the Auth bound to the context, if any.
func Get ¶
func Get(sid string) (*SessionStore, error)
func Start ¶
func Start(w http.ResponseWriter, r *http.Request) (store *SessionStore, err error)
func (*SessionStore) CreatedAt ¶
func (p *SessionStore) CreatedAt() int64
func (*SessionStore) Delete ¶
func (p *SessionStore) Delete(k string) error
Delete value in mysql session
func (*SessionStore) Reset ¶
func (p *SessionStore) Reset() error
Reset clear all values in mysql session
func (*SessionStore) Set ¶
func (p *SessionStore) Set(k, v string) error
Set value in mysql session. it is temp value in map.
func (*SessionStore) Sid ¶
func (p *SessionStore) Sid() string
Sid get session id of this mysql session store
func (*SessionStore) Update ¶
func (p *SessionStore) Update(w http.ResponseWriter) error
Click to show internal directories.
Click to hide internal directories.