diff --git a/README.md b/README.md index c8784f0..37ccf3e 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Sessions can be stored to any backend by implementing the [store](/store.go) int * [in-memory](/stores/memory) * [redis](/stores/redis) -* [securecookie](/stores/securecookie) +* [secure cookie](/stores/securecookie) # Usage Check the [examples](/examples) directory for complete examples. @@ -33,7 +33,7 @@ Stores can be registered to a session instance by using `Use` method. ```go sess := simplesessions.New(simplesessions.Options{}) -sess.UseStore(memorystore.New()) +sess.UseStore(memory.New()) ``` ## Connecting an HTTP handler @@ -94,7 +94,7 @@ func handler(w http.ResponseWriter, r *http.Request) { // call `Commit` method when you set all the values. err = sess.Set("somekey", "somevalue") err = sess.Set("someotherkey", 10) - err = sess.commit() + err = sess.Commit() // Use `Get` method to get a field from current session. The result will be an interface // so you can use helper methods like @@ -124,7 +124,7 @@ func main() { // cookie domain, is secure cookie etc. Check `Options` struct for more options. sessMan := simplesessions.New(simplesessions.Options{}) // Create a new store instance and attach to session manager - sessMan.UseStore(memorystore.New()) + sessMan.UseStore(memory.New()) // Register callbacks for read and write cookie // Get cookie callback should get cookie based on cookie name and // sent back in net/http cookie format. diff --git a/examples/fasthttp-inmemory/main.go b/examples/fasthttp-inmemory/main.go index 5732bb8..c7293d9 100644 --- a/examples/fasthttp-inmemory/main.go +++ b/examples/fasthttp-inmemory/main.go @@ -100,7 +100,7 @@ func setCookie(cookie *http.Cookie, w interface{}) error { func main() { sessionManager = simplesessions.New(simplesessions.Options{}) - sessionManager.UseStore(memorystore.New()) + sessionManager.UseStore(memory.New()) sessionManager.RegisterGetCookie(getCookie) sessionManager.RegisterSetCookie(setCookie) diff --git a/examples/fasthttp-redis/main.go b/examples/fasthttp-redis/main.go index 446c8fe..110025c 100644 --- a/examples/fasthttp-redis/main.go +++ b/examples/fasthttp-redis/main.go @@ -8,7 +8,7 @@ import ( "github.com/gomodule/redigo/redis" "github.com/valyala/fasthttp" "github.com/vividvilla/simplesessions" - "github.com/vividvilla/simplesessions/stores/redis" + redisstore "github.com/vividvilla/simplesessions/stores/redis" ) var ( diff --git a/examples/nethttp-inmemory/main.go b/examples/nethttp-inmemory/main.go index 8bc78b1..8a53517 100644 --- a/examples/nethttp-inmemory/main.go +++ b/examples/nethttp-inmemory/main.go @@ -71,7 +71,7 @@ func setCookie(cookie *http.Cookie, w interface{}) error { func main() { sessionManager = simplesessions.New(simplesessions.Options{}) - sessionManager.UseStore(memorystore.New()) + sessionManager.UseStore(memory.New()) sessionManager.RegisterGetCookie(getCookie) sessionManager.RegisterSetCookie(setCookie) diff --git a/examples/nethttp-redis/main.go b/examples/nethttp-redis/main.go index a8d6853..746d354 100644 --- a/examples/nethttp-redis/main.go +++ b/examples/nethttp-redis/main.go @@ -8,7 +8,7 @@ import ( "github.com/gomodule/redigo/redis" "github.com/vividvilla/simplesessions" - "github.com/vividvilla/simplesessions/stores/redis" + redisstore "github.com/vividvilla/simplesessions/stores/redis" ) var ( diff --git a/examples/nethttp-secure-cookie/main.go b/examples/nethttp-secure-cookie/main.go index 7cd7c10..636f14b 100644 --- a/examples/nethttp-secure-cookie/main.go +++ b/examples/nethttp-secure-cookie/main.go @@ -71,7 +71,7 @@ func setCookie(cookie *http.Cookie, w interface{}) error { func main() { sessionManager = simplesessions.New(simplesessions.Options{}) - sessionManager.UseStore(securecookiestore.New( + sessionManager.UseStore(securecookie.New( []byte("0dIHy6S2uBuKaNnTUszB218L898ikGYA"), []byte("0dIHy6S2uBuKaNnTUszB218L898ikGYA"), )) diff --git a/stores/memory/memory_store.go b/stores/memory/store.go similarity index 74% rename from stores/memory/memory_store.go rename to stores/memory/store.go index 7a9ef99..6d43569 100644 --- a/stores/memory/memory_store.go +++ b/stores/memory/store.go @@ -1,4 +1,4 @@ -package memorystore +package memory import ( "sync" @@ -10,8 +10,8 @@ const ( sessionIDLen = 32 ) -// MemoryStore represents in-memory session store -type MemoryStore struct { +// Store represents in-memory session store +type Store struct { // map to store all sessions and its values sessions map[string]map[string]interface{} @@ -19,26 +19,26 @@ type MemoryStore struct { } // New creates a new in-memory store instance -func New() *MemoryStore { - return &MemoryStore{ +func New() *Store { + return &Store{ sessions: make(map[string]map[string]interface{}), } } // isValidSessionID checks is the given session id is valid. -func (s *MemoryStore) isValidSessionID(sess *simplesessions.Session, id string) bool { +func (s *Store) isValidSessionID(sess *simplesessions.Session, id string) bool { return len(id) == sessionIDLen && sess.IsValidRandomString(id) } // IsValid checks if the session is set for the id -func (s *MemoryStore) IsValid(sess *simplesessions.Session, id string) (bool, error) { +func (s *Store) IsValid(sess *simplesessions.Session, id string) (bool, error) { return s.isValidSessionID(sess, id), nil } // Create creates a new session id and returns it. This doesn't create the session in // sessions map since memory can be saved by not storing empty sessions and system // can not be stressed by just creating new sessions -func (s *MemoryStore) Create(sess *simplesessions.Session) (string, error) { +func (s *Store) Create(sess *simplesessions.Session) (string, error) { id, err := sess.GenerateRandomString(sessionIDLen) if err != nil { return "", err @@ -48,7 +48,7 @@ func (s *MemoryStore) Create(sess *simplesessions.Session) (string, error) { } // Get gets a field in session -func (s *MemoryStore) Get(sess *simplesessions.Session, id, key string) (interface{}, error) { +func (s *Store) Get(sess *simplesessions.Session, id, key string) (interface{}, error) { if !s.isValidSessionID(sess, id) { return nil, simplesessions.ErrInvalidSession } @@ -72,7 +72,7 @@ func (s *MemoryStore) Get(sess *simplesessions.Session, id, key string) (interfa } // GetMulti gets a map for values for multiple keys. If key is not present in session then nil is returned. -func (s *MemoryStore) GetMulti(sess *simplesessions.Session, id string, keys ...string) (map[string]interface{}, error) { +func (s *Store) GetMulti(sess *simplesessions.Session, id string, keys ...string) (map[string]interface{}, error) { // Check if valid session if !s.isValidSessionID(sess, id) { return nil, simplesessions.ErrInvalidSession @@ -101,7 +101,7 @@ func (s *MemoryStore) GetMulti(sess *simplesessions.Session, id string, keys ... } // GetAll gets all fields in session -func (s *MemoryStore) GetAll(sess *simplesessions.Session, id string) (map[string]interface{}, error) { +func (s *Store) GetAll(sess *simplesessions.Session, id string) (map[string]interface{}, error) { // Check if valid session if !s.isValidSessionID(sess, id) { return nil, simplesessions.ErrInvalidSession @@ -115,7 +115,7 @@ func (s *MemoryStore) GetAll(sess *simplesessions.Session, id string) (map[strin } // Set sets a value to given session but stored only on commit -func (s *MemoryStore) Set(sess *simplesessions.Session, id, key string, val interface{}) error { +func (s *Store) Set(sess *simplesessions.Session, id, key string, val interface{}) error { // Check if valid session if !s.isValidSessionID(sess, id) { return simplesessions.ErrInvalidSession @@ -135,12 +135,12 @@ func (s *MemoryStore) Set(sess *simplesessions.Session, id, key string, val inte } // Commit does nothing here since Set sets the value. -func (s *MemoryStore) Commit(sess *simplesessions.Session, id string) error { +func (s *Store) Commit(sess *simplesessions.Session, id string) error { return nil } // Delete deletes a key from session. -func (s *MemoryStore) Delete(sess *simplesessions.Session, id string, key string) error { +func (s *Store) Delete(sess *simplesessions.Session, id string, key string) error { // Check if valid session if !s.isValidSessionID(sess, id) { return simplesessions.ErrInvalidSession @@ -161,7 +161,7 @@ func (s *MemoryStore) Delete(sess *simplesessions.Session, id string, key string } // Clear clears session in redis. -func (s *MemoryStore) Clear(sess *simplesessions.Session, id string) error { +func (s *Store) Clear(sess *simplesessions.Session, id string) error { // Check if valid session if !s.isValidSessionID(sess, id) { return simplesessions.ErrInvalidSession @@ -179,7 +179,7 @@ func (s *MemoryStore) Clear(sess *simplesessions.Session, id string) error { } // Int is a helper method to type assert as integer -func (s *MemoryStore) Int(r interface{}, err error) (int, error) { +func (s *Store) Int(r interface{}, err error) (int, error) { if err != nil { return 0, err } @@ -193,7 +193,7 @@ func (s *MemoryStore) Int(r interface{}, err error) (int, error) { } // Int64 is a helper method to type assert as Int64 -func (s *MemoryStore) Int64(r interface{}, err error) (int64, error) { +func (s *Store) Int64(r interface{}, err error) (int64, error) { if err != nil { return 0, err } @@ -207,7 +207,7 @@ func (s *MemoryStore) Int64(r interface{}, err error) (int64, error) { } // UInt64 is a helper method to type assert as UInt64 -func (s *MemoryStore) UInt64(r interface{}, err error) (uint64, error) { +func (s *Store) UInt64(r interface{}, err error) (uint64, error) { if err != nil { return 0, err } @@ -221,7 +221,7 @@ func (s *MemoryStore) UInt64(r interface{}, err error) (uint64, error) { } // Float64 is a helper method to type assert as Float64 -func (s *MemoryStore) Float64(r interface{}, err error) (float64, error) { +func (s *Store) Float64(r interface{}, err error) (float64, error) { if err != nil { return 0, err } @@ -235,7 +235,7 @@ func (s *MemoryStore) Float64(r interface{}, err error) (float64, error) { } // String is a helper method to type assert as String -func (s *MemoryStore) String(r interface{}, err error) (string, error) { +func (s *Store) String(r interface{}, err error) (string, error) { if err != nil { return "", err } @@ -249,7 +249,7 @@ func (s *MemoryStore) String(r interface{}, err error) (string, error) { } // Bytes is a helper method to type assert as Bytes -func (s *MemoryStore) Bytes(r interface{}, err error) ([]byte, error) { +func (s *Store) Bytes(r interface{}, err error) ([]byte, error) { if err != nil { return nil, err } @@ -263,7 +263,7 @@ func (s *MemoryStore) Bytes(r interface{}, err error) ([]byte, error) { } // Bool is a helper method to type assert as Bool -func (s *MemoryStore) Bool(r interface{}, err error) (bool, error) { +func (s *Store) Bool(r interface{}, err error) (bool, error) { if err != nil { return false, err } diff --git a/stores/memory/memory_store_test.go b/stores/memory/store_test.go similarity index 99% rename from stores/memory/memory_store_test.go rename to stores/memory/store_test.go index 0306e96..509103e 100644 --- a/stores/memory/memory_store_test.go +++ b/stores/memory/store_test.go @@ -1,4 +1,4 @@ -package memorystore +package memory import ( "errors" diff --git a/stores/redis/redis_store.go b/stores/redis/store.go similarity index 75% rename from stores/redis/redis_store.go rename to stores/redis/store.go index b8cb27f..66a1df0 100644 --- a/stores/redis/redis_store.go +++ b/stores/redis/store.go @@ -1,4 +1,4 @@ -package redisstore +package redis import ( "errors" @@ -9,9 +9,9 @@ import ( "github.com/vividvilla/simplesessions" ) -// RedisStore represents redis session store for simple sessions. +// Store represents redis session store for simple sessions. // Each session is stored as redis hashmap. -type RedisStore struct { +type Store struct { // Maximum lifetime sessions has to be persisted. ttl time.Duration @@ -33,8 +33,8 @@ const ( ) // New creates a new in-memory store instance -func New(pool *redis.Pool) *RedisStore { - return &RedisStore{ +func New(pool *redis.Pool) *Store { + return &Store{ pool: pool, prefix: defaultPrefix, tempSetMap: make(map[string]map[string]interface{}), @@ -42,28 +42,28 @@ func New(pool *redis.Pool) *RedisStore { } // SetPrefix sets session id prefix in backend -func (s *RedisStore) SetPrefix(val string) { +func (s *Store) SetPrefix(val string) { s.prefix = val } // SetTTL sets TTL for session in redis. -func (s *RedisStore) SetTTL(d time.Duration) { +func (s *Store) SetTTL(d time.Duration) { s.ttl = d } // isValidSessionID checks is the given session id is valid. -func (s *RedisStore) isValidSessionID(sess *simplesessions.Session, id string) bool { +func (s *Store) isValidSessionID(sess *simplesessions.Session, id string) bool { return len(id) == sessionIDLen && sess.IsValidRandomString(id) } // IsValid checks if the session is set for the id. -func (s *RedisStore) IsValid(sess *simplesessions.Session, id string) (bool, error) { +func (s *Store) IsValid(sess *simplesessions.Session, id string) (bool, error) { // Validate session is valid generate string or not return s.isValidSessionID(sess, id), nil } // Create returns a new session id but doesn't stores it in redis since empty hashmap can't be created. -func (s *RedisStore) Create(sess *simplesessions.Session) (string, error) { +func (s *Store) Create(sess *simplesessions.Session) (string, error) { id, err := sess.GenerateRandomString(sessionIDLen) if err != nil { return "", err @@ -73,7 +73,7 @@ func (s *RedisStore) Create(sess *simplesessions.Session) (string, error) { } // Get gets a field in hashmap. If field is nill then ErrFieldNotFound is raised -func (s *RedisStore) Get(sess *simplesessions.Session, id, key string) (interface{}, error) { +func (s *Store) Get(sess *simplesessions.Session, id, key string) (interface{}, error) { // Check if valid session if !s.isValidSessionID(sess, id) { return nil, simplesessions.ErrInvalidSession @@ -91,7 +91,7 @@ func (s *RedisStore) Get(sess *simplesessions.Session, id, key string) (interfac } // GetMulti gets a map for values for multiple keys. If key is not found then its set as nil. -func (s *RedisStore) GetMulti(sess *simplesessions.Session, id string, keys ...string) (map[string]interface{}, error) { +func (s *Store) GetMulti(sess *simplesessions.Session, id string, keys ...string) (map[string]interface{}, error) { // Check if valid session if !s.isValidSessionID(sess, id) { return nil, simplesessions.ErrInvalidSession @@ -123,7 +123,7 @@ func (s *RedisStore) GetMulti(sess *simplesessions.Session, id string, keys ...s } // GetAll gets all fields from hashmap. -func (s *RedisStore) GetAll(sess *simplesessions.Session, id string) (map[string]interface{}, error) { +func (s *Store) GetAll(sess *simplesessions.Session, id string) (map[string]interface{}, error) { // Check if valid session if !s.isValidSessionID(sess, id) { return nil, simplesessions.ErrInvalidSession @@ -136,7 +136,7 @@ func (s *RedisStore) GetAll(sess *simplesessions.Session, id string) (map[string } // Set sets a value to given session but stored only on commit -func (s *RedisStore) Set(sess *simplesessions.Session, id, key string, val interface{}) error { +func (s *Store) Set(sess *simplesessions.Session, id, key string, val interface{}) error { // Check if valid session if !s.isValidSessionID(sess, id) { return simplesessions.ErrInvalidSession @@ -157,7 +157,7 @@ func (s *RedisStore) Set(sess *simplesessions.Session, id, key string, val inter } // Commit sets all set values -func (s *RedisStore) Commit(sess *simplesessions.Session, id string) error { +func (s *Store) Commit(sess *simplesessions.Session, id string) error { // Check if valid session if !s.isValidSessionID(sess, id) { return simplesessions.ErrInvalidSession @@ -197,7 +197,7 @@ func (s *RedisStore) Commit(sess *simplesessions.Session, id string) error { } // Delete deletes a key from redis session hashmap. -func (s *RedisStore) Delete(sess *simplesessions.Session, id string, key string) error { +func (s *Store) Delete(sess *simplesessions.Session, id string, key string) error { // Check if valid session if !s.isValidSessionID(sess, id) { return simplesessions.ErrInvalidSession @@ -216,7 +216,7 @@ func (s *RedisStore) Delete(sess *simplesessions.Session, id string, key string) } // Clear clears session in redis. -func (s *RedisStore) Clear(sess *simplesessions.Session, id string) error { +func (s *Store) Clear(sess *simplesessions.Session, id string) error { // Check if valid session if !s.isValidSessionID(sess, id) { return simplesessions.ErrInvalidSession @@ -230,7 +230,7 @@ func (s *RedisStore) Clear(sess *simplesessions.Session, id string) error { } // interfaceMap is a helper method which converts HGETALL reply to map of string interface -func (s *RedisStore) interfaceMap(result interface{}, err error) (map[string]interface{}, error) { +func (s *Store) interfaceMap(result interface{}, err error) (map[string]interface{}, error) { values, err := redis.Values(result, err) if err != nil { return nil, err @@ -254,36 +254,36 @@ func (s *RedisStore) interfaceMap(result interface{}, err error) (map[string]int } // Int returns redis reply as integer. -func (s *RedisStore) Int(r interface{}, err error) (int, error) { +func (s *Store) Int(r interface{}, err error) (int, error) { return redis.Int(r, err) } // Int64 returns redis reply as Int64. -func (s *RedisStore) Int64(r interface{}, err error) (int64, error) { +func (s *Store) Int64(r interface{}, err error) (int64, error) { return redis.Int64(r, err) } // UInt64 returns redis reply as UInt64. -func (s *RedisStore) UInt64(r interface{}, err error) (uint64, error) { +func (s *Store) UInt64(r interface{}, err error) (uint64, error) { return redis.Uint64(r, err) } // Float64 returns redis reply as Float64. -func (s *RedisStore) Float64(r interface{}, err error) (float64, error) { +func (s *Store) Float64(r interface{}, err error) (float64, error) { return redis.Float64(r, err) } // String returns redis reply as String. -func (s *RedisStore) String(r interface{}, err error) (string, error) { +func (s *Store) String(r interface{}, err error) (string, error) { return redis.String(r, err) } // Bytes returns redis reply as Bytes. -func (s *RedisStore) Bytes(r interface{}, err error) ([]byte, error) { +func (s *Store) Bytes(r interface{}, err error) ([]byte, error) { return redis.Bytes(r, err) } // Bool returns redis reply as Bool. -func (s *RedisStore) Bool(r interface{}, err error) (bool, error) { +func (s *Store) Bool(r interface{}, err error) (bool, error) { return redis.Bool(r, err) } diff --git a/stores/redis/redis_store_test.go b/stores/redis/store_test.go similarity index 99% rename from stores/redis/redis_store_test.go rename to stores/redis/store_test.go index 99f3bdc..145b6d3 100644 --- a/stores/redis/redis_store_test.go +++ b/stores/redis/store_test.go @@ -1,4 +1,4 @@ -package redisstore +package redis import ( "errors" diff --git a/stores/securecookie/secure_cookie.go b/stores/securecookie/secure_cookie.go index 3e4e41b..418fbee 100644 --- a/stores/securecookie/secure_cookie.go +++ b/stores/securecookie/secure_cookie.go @@ -1,4 +1,4 @@ -package securecookiestore +package securecookie import ( "sync" @@ -11,8 +11,8 @@ const ( cookieName = "session" ) -// SecureCookieStore represents secure cookie session store -type SecureCookieStore struct { +// Store represents secure cookie session store +type Store struct { // Temp map to store values before commit. tempSetMap map[string]map[string]interface{} mu sync.RWMutex @@ -27,27 +27,27 @@ type SecureCookieStore struct { // The blockKey is optional, used to encrypt the cookie value -- set it to nil to not use encryption. // If set, the length must correspond to the block size of the encryption algorithm. // For AES, used by default, valid lengths are 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256. -func New(secretKey []byte, blockKey []byte) *SecureCookieStore { - return &SecureCookieStore{ +func New(secretKey []byte, blockKey []byte) *Store { + return &Store{ sc: securecookie.New(secretKey, blockKey), tempSetMap: make(map[string]map[string]interface{}), } } // encode and encrypt given interface -func (s *SecureCookieStore) encode(val interface{}) (string, error) { +func (s *Store) encode(val interface{}) (string, error) { return s.sc.Encode(cookieName, val) } // decode encoded value to map -func (s *SecureCookieStore) decode(cookieVal string) (map[string]interface{}, error) { +func (s *Store) decode(cookieVal string) (map[string]interface{}, error) { val := make(map[string]interface{}) err := s.sc.Decode(cookieName, cookieVal, &val) return val, err } // IsValid checks if the given cookie value is valid. -func (s *SecureCookieStore) IsValid(sess *simplesessions.Session, cv string) (bool, error) { +func (s *Store) IsValid(sess *simplesessions.Session, cv string) (bool, error) { if _, err := s.decode(cv); err != nil { return false, nil } @@ -56,13 +56,13 @@ func (s *SecureCookieStore) IsValid(sess *simplesessions.Session, cv string) (bo } // Create creates a new secure cookie session with empty map. -func (s *SecureCookieStore) Create(sess *simplesessions.Session) (string, error) { +func (s *Store) Create(sess *simplesessions.Session) (string, error) { // Create empty cookie return s.encode(make(map[string]interface{})) } // Get returns a field value from session -func (s *SecureCookieStore) Get(sess *simplesessions.Session, cv, key string) (interface{}, error) { +func (s *Store) Get(sess *simplesessions.Session, cv, key string) (interface{}, error) { // Decode cookie value vals, err := s.decode(cv) if err != nil { @@ -80,7 +80,7 @@ func (s *SecureCookieStore) Get(sess *simplesessions.Session, cv, key string) (i // GetMulti returns values for multiple fields in session. // If a field is not present then nil is returned. -func (s *SecureCookieStore) GetMulti(sess *simplesessions.Session, cv string, keys ...string) (map[string]interface{}, error) { +func (s *Store) GetMulti(sess *simplesessions.Session, cv string, keys ...string) (map[string]interface{}, error) { // Decode cookie value vals, err := s.decode(cv) if err != nil { @@ -97,7 +97,7 @@ func (s *SecureCookieStore) GetMulti(sess *simplesessions.Session, cv string, ke } // GetAll returns all field for given session. -func (s *SecureCookieStore) GetAll(sess *simplesessions.Session, cv string) (map[string]interface{}, error) { +func (s *Store) GetAll(sess *simplesessions.Session, cv string) (map[string]interface{}, error) { vals, err := s.decode(cv) if err != nil { return nil, simplesessions.ErrInvalidSession @@ -107,7 +107,7 @@ func (s *SecureCookieStore) GetAll(sess *simplesessions.Session, cv string) (map } // Set sets a field in session but not saved untill commit is called. -func (s *SecureCookieStore) Set(sess *simplesessions.Session, cv, key string, val interface{}) error { +func (s *Store) Set(sess *simplesessions.Session, cv, key string, val interface{}) error { s.mu.Lock() defer s.mu.Unlock() @@ -123,7 +123,7 @@ func (s *SecureCookieStore) Set(sess *simplesessions.Session, cv, key string, va } // Commit saves all the field set previously to cookie. -func (s *SecureCookieStore) Commit(sess *simplesessions.Session, cv string) error { +func (s *Store) Commit(sess *simplesessions.Session, cv string) error { // Decode current cookie vals, err := s.decode(cv) if err != nil { @@ -159,7 +159,7 @@ func (s *SecureCookieStore) Commit(sess *simplesessions.Session, cv string) erro } // Delete deletes a field from session. -func (s *SecureCookieStore) Delete(sess *simplesessions.Session, cv, key string) error { +func (s *Store) Delete(sess *simplesessions.Session, cv, key string) error { // Decode current cookie vals, err := s.decode(cv) if err != nil { @@ -185,7 +185,7 @@ func (s *SecureCookieStore) Delete(sess *simplesessions.Session, cv, key string) } // Clear clears the session. -func (s *SecureCookieStore) Clear(sess *simplesessions.Session, id string) error { +func (s *Store) Clear(sess *simplesessions.Session, id string) error { encoded, err := s.encode(make(map[string]interface{})) if err != nil { return err @@ -196,7 +196,7 @@ func (s *SecureCookieStore) Clear(sess *simplesessions.Session, id string) error } // Int is a helper method to type assert as integer -func (s *SecureCookieStore) Int(r interface{}, err error) (int, error) { +func (s *Store) Int(r interface{}, err error) (int, error) { if err != nil { return 0, err } @@ -210,7 +210,7 @@ func (s *SecureCookieStore) Int(r interface{}, err error) (int, error) { } // Int64 is a helper method to type assert as Int64 -func (s *SecureCookieStore) Int64(r interface{}, err error) (int64, error) { +func (s *Store) Int64(r interface{}, err error) (int64, error) { if err != nil { return 0, err } @@ -224,7 +224,7 @@ func (s *SecureCookieStore) Int64(r interface{}, err error) (int64, error) { } // UInt64 is a helper method to type assert as UInt64 -func (s *SecureCookieStore) UInt64(r interface{}, err error) (uint64, error) { +func (s *Store) UInt64(r interface{}, err error) (uint64, error) { if err != nil { return 0, err } @@ -238,7 +238,7 @@ func (s *SecureCookieStore) UInt64(r interface{}, err error) (uint64, error) { } // Float64 is a helper method to type assert as Float64 -func (s *SecureCookieStore) Float64(r interface{}, err error) (float64, error) { +func (s *Store) Float64(r interface{}, err error) (float64, error) { if err != nil { return 0, err } @@ -252,7 +252,7 @@ func (s *SecureCookieStore) Float64(r interface{}, err error) (float64, error) { } // String is a helper method to type assert as String -func (s *SecureCookieStore) String(r interface{}, err error) (string, error) { +func (s *Store) String(r interface{}, err error) (string, error) { if err != nil { return "", err } @@ -266,7 +266,7 @@ func (s *SecureCookieStore) String(r interface{}, err error) (string, error) { } // Bytes is a helper method to type assert as Bytes -func (s *SecureCookieStore) Bytes(r interface{}, err error) ([]byte, error) { +func (s *Store) Bytes(r interface{}, err error) ([]byte, error) { if err != nil { return nil, err } @@ -280,7 +280,7 @@ func (s *SecureCookieStore) Bytes(r interface{}, err error) ([]byte, error) { } // Bool is a helper method to type assert as Bool -func (s *SecureCookieStore) Bool(r interface{}, err error) (bool, error) { +func (s *Store) Bool(r interface{}, err error) (bool, error) { if err != nil { return false, err } diff --git a/stores/securecookie/secure_cookie_test.go b/stores/securecookie/secure_cookie_test.go index 234f24c..b96b8a3 100644 --- a/stores/securecookie/secure_cookie_test.go +++ b/stores/securecookie/secure_cookie_test.go @@ -1,4 +1,4 @@ -package securecookiestore +package securecookie import ( "errors"