use package level func for unmarshal
This commit is contained in:
parent
3573ac818f
commit
748c20c979
@ -14,7 +14,6 @@ type Codec struct {
|
||||
Conn io.ReadWriteCloser
|
||||
Encoder *json.Encoder
|
||||
Decoder *json.Decoder
|
||||
Unmarshaler *jsonpb.Unmarshaler
|
||||
}
|
||||
|
||||
func (c *Codec) ReadHeader(m *codec.Message, t codec.MessageType) error {
|
||||
@ -26,7 +25,7 @@ func (c *Codec) ReadBody(b interface{}) error {
|
||||
return nil
|
||||
}
|
||||
if pb, ok := b.(proto.Message); ok {
|
||||
return c.Unmarshaler.UnmarshalNext(c.Decoder, pb)
|
||||
return jsonpb.UnmarshalNext(c.Decoder, pb)
|
||||
}
|
||||
return c.Decoder.Decode(b)
|
||||
}
|
||||
@ -51,6 +50,5 @@ func NewCodec(c io.ReadWriteCloser) codec.Codec {
|
||||
Conn: c,
|
||||
Decoder: json.NewDecoder(c),
|
||||
Encoder: json.NewEncoder(c),
|
||||
Unmarshaler: &jsonpb.Unmarshaler{},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user