aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHank Shen <swh@admpub.com>2023-12-06 06:54:31 +0300
committerHank Shen <swh@admpub.com>2023-12-06 06:54:31 +0300
commitc33b59bcab7ae16914ebeae200a6195204e76b3a (patch)
tree9109c2b0a73820f37e9f4cc7a50bea73d0825d25
parent75a1bf157648c5b5c155ac81e4950bff5315c0ae (diff)
updatev1.2.3
-rw-r--r--litecodec.go (renamed from unsafecodec.go)16
-rw-r--r--litecodec_test.go (renamed from unsafecodec_test.go)6
-rw-r--r--setter.go2
3 files changed, 12 insertions, 12 deletions
diff --git a/unsafecodec.go b/litecodec.go
index 6853658..0de4674 100644
--- a/unsafecodec.go
+++ b/litecodec.go
@@ -2,17 +2,17 @@ package securecookie
import "fmt"
-var _ Codec = (*UnsafeCodec)(nil)
+var _ Codec = (*LiteCodec)(nil)
-func NewUnsafeCodec() *UnsafeCodec {
- s := &UnsafeCodec{
+func NewLiteCodec() *LiteCodec {
+ s := &LiteCodec{
sz: GobEncoder{},
}
return s
}
-// UnsafeCodec encodes and decodes
-type UnsafeCodec struct {
+// LiteCodec encodes and decodes
+type LiteCodec struct {
err error
sz Serializer
}
@@ -21,14 +21,14 @@ type UnsafeCodec struct {
//
// Default is encoding/gob. To encode special structures using encoding/gob,
// they must be registered first using gob.Register().
-func (s *UnsafeCodec) SetSerializer(sz Serializer) *UnsafeCodec {
+func (s *LiteCodec) SetSerializer(sz Serializer) *LiteCodec {
s.sz = sz
return s
}
// Encode encodes a value.
-func (s *UnsafeCodec) Encode(name string, value interface{}) (string, error) {
+func (s *LiteCodec) Encode(name string, value interface{}) (string, error) {
if s.err != nil {
return "", s.err
}
@@ -43,7 +43,7 @@ func (s *UnsafeCodec) Encode(name string, value interface{}) (string, error) {
}
// Decode decodes a value. The dst argument must be a pointer.
-func (s *UnsafeCodec) Decode(name, value string, dst interface{}, _ ...int) error {
+func (s *LiteCodec) Decode(name, value string, dst interface{}, _ ...int) error {
if s.err != nil {
return s.err
}
diff --git a/unsafecodec_test.go b/litecodec_test.go
index d295907..875ee7c 100644
--- a/unsafecodec_test.go
+++ b/litecodec_test.go
@@ -2,9 +2,9 @@ package securecookie
import "testing"
-func TestUnsafeCodec(t *testing.T) {
- c := NewUnsafeCodec()
- str := `TestUnsafeCodec`
+func TestLiteCodec(t *testing.T) {
+ c := NewLiteCodec()
+ str := `TestLiteCodec`
encoded, err := c.Encode(`name`, str)
if err != nil {
t.Error(err)
diff --git a/setter.go b/setter.go
index a82dee9..2ad7052 100644
--- a/setter.go
+++ b/setter.go
@@ -49,7 +49,7 @@ func SetSerializer(codecs []Codec, sz Serializer) {
for _, c := range codecs {
if codec, ok := c.(*SecureCookie); ok {
codec.SetSerializer(sz)
- } else if codec, ok := c.(*UnsafeCodec); ok {
+ } else if codec, ok := c.(*LiteCodec); ok {
codec.SetSerializer(sz)
}
}