ing
This commit is contained in:
parent
8712bafeb6
commit
93cffbb1e5
|
@ -22,7 +22,7 @@ type ClientCodecResponseOrNotify interface {
|
||||||
|
|
||||||
type ClientCodecResponse interface {
|
type ClientCodecResponse interface {
|
||||||
ID() interface{}
|
ID() interface{}
|
||||||
Result() interface{}
|
Result(result interface{}) error
|
||||||
Error() error
|
Error() error
|
||||||
Complete()
|
Complete()
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,10 @@ type clientRequest struct {
|
||||||
|
|
||||||
// clientResponse represents a JSON-RPC response returned to a client.
|
// clientResponse represents a JSON-RPC response returned to a client.
|
||||||
type clientResponse struct {
|
type clientResponse struct {
|
||||||
Version string `json:"jsonrpc"`
|
Version string `json:"jsonrpc"`
|
||||||
Result interface{} `json:"result,omitempty"`
|
Result *json.RawMessage `json:"result,omitempty"`
|
||||||
Error error `json:"error,omitempty"`
|
Error error `json:"error,omitempty"`
|
||||||
ID interface{} `json:"id"`
|
ID interface{} `json:"id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// clientRequest represents a JSON-RPC request sent by a client.
|
// clientRequest represents a JSON-RPC request sent by a client.
|
||||||
|
|
|
@ -47,8 +47,16 @@ func (ccr *ClientCodecResponse) ID() interface{} {
|
||||||
return ccr.response.ID
|
return ccr.response.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ccr *ClientCodecResponse) Result() interface{} {
|
func (ccr *ClientCodecResponse) Result(result interface{}) error {
|
||||||
return ccr.response.Result
|
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 {
|
func (ccr *ClientCodecResponse) Error() error {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user