golint session
This commit is contained in:
@@ -25,7 +25,7 @@ import (
|
||||
|
||||
var cookiepder = &CookieProvider{}
|
||||
|
||||
// Cookie SessionStore
|
||||
// CookieSessionStore Cookie SessionStore
|
||||
type CookieSessionStore struct {
|
||||
sid string
|
||||
values map[interface{}]interface{} // session data
|
||||
@@ -47,9 +47,8 @@ func (st *CookieSessionStore) Get(key interface{}) interface{} {
|
||||
defer st.lock.RUnlock()
|
||||
if v, ok := st.values[key]; ok {
|
||||
return v
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Delete value in cookie session
|
||||
@@ -60,7 +59,7 @@ func (st *CookieSessionStore) Delete(key interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Clean all values in cookie session
|
||||
// Flush Clean all values in cookie session
|
||||
func (st *CookieSessionStore) Flush() error {
|
||||
st.lock.Lock()
|
||||
defer st.lock.Unlock()
|
||||
@@ -68,12 +67,12 @@ func (st *CookieSessionStore) Flush() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Return id of this cookie session
|
||||
// SessionID Return id of this cookie session
|
||||
func (st *CookieSessionStore) SessionID() string {
|
||||
return st.sid
|
||||
}
|
||||
|
||||
// Write cookie session to http response cookie
|
||||
// SessionRelease Write cookie session to http response cookie
|
||||
func (st *CookieSessionStore) SessionRelease(w http.ResponseWriter) {
|
||||
str, err := encodeCookie(cookiepder.block,
|
||||
cookiepder.config.SecurityKey,
|
||||
@@ -101,14 +100,14 @@ type cookieConfig struct {
|
||||
Maxage int `json:"maxage"`
|
||||
}
|
||||
|
||||
// Cookie session provider
|
||||
// CookieProvider Cookie session provider
|
||||
type CookieProvider struct {
|
||||
maxlifetime int64
|
||||
config *cookieConfig
|
||||
block cipher.Block
|
||||
}
|
||||
|
||||
// Init cookie session provider with max lifetime and config json.
|
||||
// SessionInit Init cookie session provider with max lifetime and config json.
|
||||
// maxlifetime is ignored.
|
||||
// json config:
|
||||
// securityKey - hash string
|
||||
@@ -136,9 +135,9 @@ func (pder *CookieProvider) SessionInit(maxlifetime int64, config string) error
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get SessionStore in cooke.
|
||||
// SessionRead Get SessionStore in cooke.
|
||||
// decode cooke string to map and put into SessionStore with sid.
|
||||
func (pder *CookieProvider) SessionRead(sid string) (SessionStore, error) {
|
||||
func (pder *CookieProvider) SessionRead(sid string) (Store, error) {
|
||||
maps, _ := decodeCookie(pder.block,
|
||||
pder.config.SecurityKey,
|
||||
pder.config.SecurityName,
|
||||
@@ -150,32 +149,32 @@ func (pder *CookieProvider) SessionRead(sid string) (SessionStore, error) {
|
||||
return rs, nil
|
||||
}
|
||||
|
||||
// Cookie session is always existed
|
||||
// SessionExist Cookie session is always existed
|
||||
func (pder *CookieProvider) SessionExist(sid string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// Implement method, no used.
|
||||
func (pder *CookieProvider) SessionRegenerate(oldsid, sid string) (SessionStore, error) {
|
||||
// SessionRegenerate Implement method, no used.
|
||||
func (pder *CookieProvider) SessionRegenerate(oldsid, sid string) (Store, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// Implement method, no used.
|
||||
// SessionDestroy Implement method, no used.
|
||||
func (pder *CookieProvider) SessionDestroy(sid string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Implement method, no used.
|
||||
// SessionGC Implement method, no used.
|
||||
func (pder *CookieProvider) SessionGC() {
|
||||
return
|
||||
}
|
||||
|
||||
// Implement method, return 0.
|
||||
// SessionAll Implement method, return 0.
|
||||
func (pder *CookieProvider) SessionAll() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// Implement method, no used.
|
||||
// SessionUpdate Implement method, no used.
|
||||
func (pder *CookieProvider) SessionUpdate(sid string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user