jsonrpc

package
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "2.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Endpoint     string
	CustomHeader map[string]string
	Pre          func(req *http.Request) error
	// contains filtered or unexported fields
}

func NewJsonRpcClient

func NewJsonRpcClient(hc *http.Client, endpoint string) *Client

func (*Client) Do

func (c *Client) Do(method string, reqPtr, respPtr interface{}) (jrResp *Response, err error)

Supported Parameter Structures only 'by-name through an Object' refer https://www.jsonrpc.org/specification#parameter_structures

func (*Client) Raw

func (c *Client) Raw(reqB []byte) (resp *http.Response, err error)

type Error

type Error struct {
	Code    ErrorCode   `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode int
const (
	ErrorCodeJsonParse      ErrorCode = -32700
	ErrorCodeInvalidRequest ErrorCode = -32600
	ErrorCodeMethodNotFound ErrorCode = -32601
	ErrorCodeInvalidParams  ErrorCode = -32602
	ErrorCodeInternal       ErrorCode = -32603
	ErrorCodeServer         ErrorCode = -32000
)

type Request

type Request struct {
	Version string          `json:"jsonrpc" validate:"required,version"`
	Method  string          `json:"method" validate:"required"`
	Params  json.RawMessage `json:"params,omitempty"`
	ID      interface{}     `json:"id"`
}

type Response

type Response struct {
	Version string      `json:"jsonrpc"`
	Result  interface{} `json:"result,omitempty"`
	Error   *Error      `json:"error,omitempty"`
	ID      interface{} `json:"id,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL