From 00c28b81e5893a3ee821690b5d4e41efb36dc62a Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Sun, 5 Mar 2023 23:46:31 +0300 Subject: [PATCH] add proto codec.Frame support Signed-off-by: Vasiliy Tolstov --- xml.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/xml.go b/xml.go index 2ca6044..d5b9e87 100644 --- a/xml.go +++ b/xml.go @@ -5,6 +5,7 @@ import ( "encoding/xml" "io" + pb "go.unistack.org/micro-proto/v3/codec" "go.unistack.org/micro/v3/codec" rutil "go.unistack.org/micro/v3/util/reflect" ) @@ -32,7 +33,10 @@ func (c *xmlCodec) Marshal(v interface{}, opts ...codec.Option) ([]byte, error) v = nv } - if m, ok := v.(*codec.Frame); ok { + switch m := v.(type) { + case *codec.Frame: + return m.Data, nil + case *pb.Frame: return m.Data, nil } @@ -53,7 +57,11 @@ func (c *xmlCodec) Unmarshal(b []byte, v interface{}, opts ...codec.Option) erro v = nv } - if m, ok := v.(*codec.Frame); ok { + switch m := v.(type) { + case *codec.Frame: + m.Data = b + return nil + case *pb.Frame: m.Data = b return nil } -- 2.45.2