ing
This commit is contained in:
parent
8712bafeb6
commit
93cffbb1e5
|
@ -22,7 +22,7 @@ type ClientCodecResponseOrNotify interface {
|
|||
|
||||
type ClientCodecResponse interface {
|
||||
ID() interface{}
|
||||
Result() interface{}
|
||||
Result(result interface{}) error
|
||||
Error() error
|
||||
Complete()
|
||||
}
|
||||
|
|
|
@ -32,10 +32,10 @@ type clientRequest struct {
|
|||
|
||||
// clientResponse represents a JSON-RPC response returned to a client.
|
||||
type clientResponse struct {
|
||||
Version string `json:"jsonrpc"`
|
||||
Result interface{} `json:"result,omitempty"`
|
||||
Error error `json:"error,omitempty"`
|
||||
ID interface{} `json:"id"`
|
||||
Version string `json:"jsonrpc"`
|
||||
Result *json.RawMessage `json:"result,omitempty"`
|
||||
Error error `json:"error,omitempty"`
|
||||
ID interface{} `json:"id"`
|
||||
}
|
||||
|
||||
// clientRequest represents a JSON-RPC request sent by a client.
|
||||
|
|
|
@ -47,8 +47,16 @@ func (ccr *ClientCodecResponse) ID() interface{} {
|
|||
return ccr.response.ID
|
||||
}
|
||||
|
||||
func (ccr *ClientCodecResponse) Result() interface{} {
|
||||
return ccr.response.Result
|
||||
func (ccr *ClientCodecResponse) Result(result interface{}) error {
|
||||
if ccr.err == nil && ccr.response.Result != nil {
|
||||
if err := json.Unmarshal(*ccr.response.Result, result); err != nil {
|
||||
params := [1]interface{}{result}
|
||||
if err = json.Unmarshal(*ccr.response.Result, ¶ms); err != nil {
|
||||
ccr.err = err
|
||||
}
|
||||
}
|
||||
}
|
||||
return ccr.err
|
||||
}
|
||||
|
||||
func (ccr *ClientCodecResponse) Error() error {
|
||||
|
|
Loading…
Reference in New Issue
Block a user