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 GitHub
parent 241614ff68
commit ed83c27f0e
3 changed files with 168 additions and 4 deletions

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)
}