diff --git a/go.mod b/go.mod index 1a66c17..82377ac 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,9 @@ module go.unistack.org/micro-codec-urlencode/v4 -go 1.19 +go 1.20 require ( - go.unistack.org/micro-proto/v4 v4.0.0 + go.unistack.org/micro-proto/v4 v4.0.1 go.unistack.org/micro/v4 v4.0.1 -) - -require ( - golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect - google.golang.org/protobuf v1.28.1 // indirect + google.golang.org/protobuf v1.32.0 ) diff --git a/go.sum b/go.sum index 7e6d860..f9bd60d 100644 --- a/go.sum +++ b/go.sum @@ -1,13 +1,8 @@ -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -go.unistack.org/micro-proto/v4 v4.0.0 h1:+TAwKSlx48eLsNO2E2cO0JLE8we1KU2AuWe9Q310FuU= -go.unistack.org/micro-proto/v4 v4.0.0/go.mod h1:ArmK7o+uFvxSY3dbJhKBBX4Pm1rhWdLEFf3LxBrMtec= +go.unistack.org/micro-proto/v4 v4.0.1 h1:2RKHgtCOOcAFgKsnngGK5bqM/6MWXOjVCdw03dbuoF8= +go.unistack.org/micro-proto/v4 v4.0.1/go.mod h1:ArmK7o+uFvxSY3dbJhKBBX4Pm1rhWdLEFf3LxBrMtec= go.unistack.org/micro/v4 v4.0.1 h1:xo1IxbVfgh8i0eY0VeYa3cbb13u5n/Mxnp3FOgWD4Jo= go.unistack.org/micro/v4 v4.0.1/go.mod h1:p/J5UcSJjfHsWGT31uKoghQ5rUQZzQJBAFy+Z4+ZVMs= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= +google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I= +google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= diff --git a/urlencode.go b/urlencode.go index 22a2ffc..154ab1b 100644 --- a/urlencode.go +++ b/urlencode.go @@ -1,12 +1,14 @@ // Package urlencode provides a urlencode codec -package urlencode // import "go.unistack.org/micro-codec-urlencode/v4" +package urlencode import ( + "encoding/json" "io" pb "go.unistack.org/micro-proto/v4/codec" "go.unistack.org/micro/v4/codec" rutil "go.unistack.org/micro/v4/util/reflect" + "google.golang.org/protobuf/types/known/structpb" ) type urlencodeCodec struct { @@ -75,6 +77,16 @@ func (c *urlencodeCodec) Unmarshal(b []byte, v interface{}, opts ...codec.Option return err } + switch t := v.(type) { + case *structpb.Value: + + buf, err := json.Marshal(mp) + if err == nil { + err = t.UnmarshalJSON(buf) + } + return err + } + return rutil.Merge(v, rutil.FlattenMap(mp), rutil.Tags([]string{"protobuf", "json", "xml", "yaml"}), rutil.SliceAppend(true)) }