add websocket streaming to api rpc handler (#1326)
This commit is contained in:
parent
42e9cc97e8
commit
d0c0366e0c
8
codec.go
8
codec.go
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user