Documentation
¶
Overview ¶
Package jsonrpc is a minimal JSON-RPC implementation
Package jsonrpc is a minimal JSON-RPC implementation
Index ¶
- Constants
- func SendJSONRPCRequestAndParseResult(req JSONRPCRequest, url string, reply interface{}) (err error)
- type JSONRPCError
- type JSONRPCRequest
- type JSONRPCResponse
- func NewJSONRPCErrorResponse(id interface{}, code int, message string) *JSONRPCResponse
- func NewJSONRPCResponse(id interface{}, result json.RawMessage) *JSONRPCResponse
- func SendJSONRPCRequest(req JSONRPCRequest, url string) (res *JSONRPCResponse, err error)
- func SendNewJSONRPCRequest(id interface{}, method string, args interface{}, url string) (res *JSONRPCResponse, err error)
- type MockJSONRPCServer
Constants ¶
View Source
const ( ParseError = -32700 InvalidRequest = -32600 MethodNotFound = -32601 InvalidParams = -32602 InternalError = -32603 )
As per JSON-RPC 2.0 Specification https://www.jsonrpc.org/specification#error_object
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)
func SendNewJSONRPCRequest ¶ added in v0.2.1
func SendNewJSONRPCRequest(id interface{}, method string, args interface{}, url string) (res *JSONRPCResponse, err error)
SendNewJSONRPCRequest constructs a request and sends it to the URL
type MockJSONRPCServer ¶ added in v0.3.1
type MockJSONRPCServer struct { URL string // contains filtered or unexported fields }
func NewMockJSONRPCServer ¶ added in v0.3.1
func NewMockJSONRPCServer() *MockJSONRPCServer
Click to show internal directories.
Click to hide internal directories.