summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHank Shen <swh@admpub.com>2023-10-15 06:47:40 +0300
committerHank Shen <swh@admpub.com>2023-10-15 06:47:40 +0300
commit8ec3d1ab52c633fbec232b62d021679b84730d18 (patch)
tree6cd4ac2a8ecdf240e8c01967fc8ff4855e52747f
parent1cb0c5289093305a0f28b3371fd38e792d9617e1 (diff)
updatev1.2.0
-rw-r--r--setter.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/setter.go b/setter.go
new file mode 100644
index 0000000..cb56171
--- /dev/null
+++ b/setter.go
@@ -0,0 +1,54 @@
+package securecookie
+
+import (
+ "crypto/cipher"
+ "hash"
+)
+
+func SetMaxLength(codecs []Codec, l int) {
+ for _, c := range codecs {
+ if codec, ok := c.(*SecureCookie); ok {
+ codec.MaxLength(l)
+ }
+ }
+}
+
+func SetMaxAge(codecs []Codec, l int) {
+ for _, c := range codecs {
+ if codec, ok := c.(*SecureCookie); ok {
+ codec.MaxAge(l)
+ }
+ }
+}
+
+func SetMinAge(codecs []Codec, l int) {
+ for _, c := range codecs {
+ if codec, ok := c.(*SecureCookie); ok {
+ codec.MinAge(l)
+ }
+ }
+}
+
+func SetHashFunc(codecs []Codec, f func() hash.Hash) {
+ for _, c := range codecs {
+ if codec, ok := c.(*SecureCookie); ok {
+ codec.HashFunc(f)
+ }
+ }
+}
+
+func SetBlockFunc(codecs []Codec, f func([]byte) (cipher.Block, error)) {
+ for _, c := range codecs {
+ if codec, ok := c.(*SecureCookie); ok {
+ codec.BlockFunc(f)
+ }
+ }
+}
+
+func SetSerializer(codecs []Codec, sz Serializer) {
+ for _, c := range codecs {
+ if codec, ok := c.(*SecureCookie); ok {
+ codec.SetSerializer(sz)
+ }
+ }
+}