further codec changes

This commit is contained in:
Asim Aslam
2019-01-08 15:38:25 +00:00
parent 216dbb771a
commit 4cb41721f1
13 changed files with 139 additions and 121 deletions

View File

@@ -22,11 +22,18 @@ func (c *Codec) ReadBody(b interface{}) error {
if err != nil {
return err
}
if b == nil {
return nil
}
return proto.Unmarshal(buf, b.(proto.Message))
}
func (c *Codec) Write(m *codec.Message, b interface{}) error {
buf, err := proto.Marshal(b.(proto.Message))
p, ok := b.(proto.Message)
if !ok {
return nil
}
buf, err := proto.Marshal(p)
if err != nil {
return err
}