Documentation
¶
Overview ¶
Package jsonrpc is a minimal JSON-RPC implementation
Package jsonrpc is a minimal JSON-RPC implementation
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SendJSONRPCRequestAndParseResult ¶
func SendJSONRPCRequestAndParseResult(req JSONRPCRequest, url string, reply interface{}) (err error)
SendJSONRPCRequestAndParseResult sends the request and decodes the response into the reply interface. If the JSON-RPC response contains an Error property, the it's returned as this function's error.
Types ¶
type JSONRPCError ¶
JSONRPCError as per spec: https://www.jsonrpc.org/specification#error_object
func (JSONRPCError) Error ¶
func (err JSONRPCError) Error() string
type JSONRPCRequest ¶
type JSONRPCRequest struct { ID interface{} `json:"id"` Method string `json:"method"` Params [1]interface{} `json:"params"` Version string `json:"jsonrpc,omitempty"` }
func NewJSONRPCRequest ¶
func NewJSONRPCRequest(id interface{}, method string, args interface{}) *JSONRPCRequest
type JSONRPCResponse ¶
type JSONRPCResponse struct { ID interface{} `json:"id"` Result json.RawMessage `json:"result,omitempty"` Error *JSONRPCError `json:"error,omitempty"` Version string `json:"jsonrpc"` }
func NewJSONRPCErrorResponse ¶
func NewJSONRPCErrorResponse(id interface{}, code int, message string) *JSONRPCResponse
func NewJSONRPCResponse ¶
func NewJSONRPCResponse(id interface{}, result json.RawMessage) *JSONRPCResponse
func SendJSONRPCRequest ¶
func SendJSONRPCRequest(req JSONRPCRequest, url string) (res *JSONRPCResponse, err error)
SendJSONRPCRequest sends the request to URL and returns the general JsonRpcResponse, or an error (note: not the JSONRPCError)
Click to show internal directories.
Click to hide internal directories.