Documentation
¶
Index ¶
Constants ¶
const ( INVALID_REQUEST = -32600 METHOD_NOT_FOUND = -32601 INVALID_PARAMS = -32602 INTERNAL_ERROR = -32603 PARSE_ERROR = -32700 )
JSON-RPC 2.0 error codes.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Codec ¶
type Codec interface {
EncodeBytes(interface{}) ([]byte, error)
Encode(interface{}, io.Writer) error
DecodeBytes(interface{}, []byte) error
DecodeBytesPtr(interface{}, []byte) error
Decode(interface{}, io.Reader) error
}
Used for rpc request and response data.
type RPCErrorResponse ¶
type RPCErrorResponse struct {
Error *RPCError `json:"error"`
Id string `json:"id"`
JSONRPC string `json:"jsonrpc"`
}
RPCErrorResponse MUST NOT contain the result member if an error occured
func (*RPCErrorResponse) AssertIsRPCResponse ¶
func (rpcErrorResponse *RPCErrorResponse) AssertIsRPCResponse() bool
AssertIsRPCResponse implements a marker method for RPCErrorResponse to implement the interface RPCResponse
type RPCRequest ¶
type RPCRequest struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params json.RawMessage `json:"params"`
Id string `json:"id"`
}
Request and Response objects. Id is a string. Error data not used. Refer to JSON-RPC specification http://www.jsonrpc.org/specification
func NewRPCRequest ¶ added in v0.16.2
func NewRPCRequest(id string, method string, params json.RawMessage) *RPCRequest
Create a new RPC request. This is the generic struct that is passed to RPC methods
type RPCResponse ¶
type RPCResponse interface {
AssertIsRPCResponse() bool
}
RPCResponse MUST follow the JSON-RPC specification for Response object reference: http://www.jsonrpc.org/specification#response_object
func NewRPCErrorResponse ¶
func NewRPCErrorResponse(id string, code int, message string) RPCResponse
NewRPCErrorResponse creates a new error-response object from the error code and message
func NewRPCResponse ¶
func NewRPCResponse(id string, res interface{}) RPCResponse
NewRPCResponse creates a new response object from a result
type RPCResultResponse ¶
type RPCResultResponse struct {
Result interface{} `json:"result"`
Id string `json:"id"`
JSONRPC string `json:"jsonrpc"`
}
RPCResultResponse MUST NOT contain the error member if no error occurred
func (*RPCResultResponse) AssertIsRPCResponse ¶
func (rpcResultResponse *RPCResultResponse) AssertIsRPCResponse() bool
AssertIsRPCResponse implements a marker method for RPCResultResponse to implement the interface RPCResponse