Adding gzip encoding helpers
package dsl
import (
+ "bytes"
+ "compress/gzip"
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
@@ -120,6 +122,16 @@ var functions = map[string]govaluate.ExpressionFunction{
return sEnc, nil
},
+ "gzip": func(args ...interface{}) (interface{}, error) {
+ if len(args) != 1 {
+ return nil, ErrDSLArguments
+ }
+ buffer := &bytes.Buffer{}
+ if _, err := gzip.NewWriter(buffer).Write([]byte(args[0].(string))); err != nil {
+ return "", err
+ }
+ return buffer.String(), nil
+ },
// python encodes to base64 with lines of 76 bytes terminated by new line "\n"
"base64_py": func(args ...interface{}) (interface{}, error) {
if len(args) != 1 {
