diff options
author | Kamil Kisiel <kamil@kamilkisiel.net> | 2013-12-01 01:25:48 +0400 |
---|---|---|
committer | Kamil Kisiel <kamil@kamilkisiel.net> | 2013-12-01 01:25:48 +0400 |
commit | 6e2523a6cb00e3df30adb7c3d188f33d39dd42d6 (patch) | |
tree | 97280c4391893e020dce55fae08700e40b6ff82b /securecookie.go | |
parent | 155134204c034796bcd7a72c1e1b53ba005735c6 (diff) |
Add travis.yml
Diffstat (limited to 'securecookie.go')
-rw-r--r-- | securecookie.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/securecookie.go b/securecookie.go index 2f34bfe..9147f6a 100644 --- a/securecookie.go +++ b/securecookie.go @@ -22,6 +22,11 @@ import ( "time" ) +var ( + errNoCodecs = errors.New("securecookie: no codecs provided") + errHashKeyNotSet = errors.New("securecookie: hash key is not set") +) + // Codec defines an interface to encode and decode cookie values. type Codec interface { Encode(name string, value interface{}) (string, error) @@ -46,7 +51,7 @@ func New(hashKey, blockKey []byte) *SecureCookie { maxLength: 4096, } if hashKey == nil { - s.err = errors.New("securecookie: hash key is not set") + s.err = errHashKeyNotSet } if blockKey != nil { s.BlockFunc(aes.NewCipher) @@ -130,7 +135,7 @@ func (s *SecureCookie) Encode(name string, value interface{}) (string, error) { return "", s.err } if s.hashKey == nil { - s.err = errors.New("securecookie: hash key is not set") + s.err = errHashKeyNotSet return "", s.err } var err error @@ -174,7 +179,7 @@ func (s *SecureCookie) Decode(name, value string, dst interface{}) error { return s.err } if s.hashKey == nil { - s.err = errors.New("securecookie: hash key is not set") + s.err = errHashKeyNotSet return s.err } // 1. Check length. @@ -357,8 +362,6 @@ func CodecsFromPairs(keyPairs ...[]byte) []Codec { return codecs } -var errNoCodecs = errors.New("securecookie: no codecs provided") - // EncodeMulti encodes a cookie value using a group of codecs. // // The codecs are tried in order. Multiple codecs are accepted to allow |