add websocket streaming to api rpc handler (#1326)

This commit is contained in:
Asim Aslam 2020-03-10 15:21:43 +00:00 committed by Vasiliy Tolstov
parent 42e9cc97e8
commit d0c0366e0c

View File

@ -117,7 +117,9 @@ func (jsonCodec) Marshal(v interface{}) ([]byte, error) {
return []byte(s), err
}
if b, ok := v.(*bytes.Frame); ok {
return b.Data, nil
}
return json.Marshal(v)
}
@ -125,6 +127,10 @@ func (jsonCodec) Unmarshal(data []byte, v interface{}) error {
if len(data) == 0 {
return nil
}
if b, ok := v.(*bytes.Frame); ok {
b.Data = data
return nil
}
if pb, ok := v.(proto.Message); ok {
return jsonpb.Unmarshal(b.NewReader(data), pb)
}