jsonrpc

package
v1.42.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Params

func Params(params ...interface{}) interface{}

Types

type Client

type Client interface {
	Call(method string, params ...interface{}) (*RPCResponse, error)
	CallCtx(ctx context.Context, method string, params ...interface{}) (*RPCResponse, error)
}

func NewClient

func NewClient(endpoint string) Client

func NewClientWithOpts

func NewClientWithOpts(endpoint string, opts *ClientOpts) Client

type ClientOpts

type ClientOpts struct {
	HTTPClient *http.Client
	Headers    map[string]string

	// HTTP Basic auth username
	BasicUser string

	// HTTP Basic auth password
	BasicPass string
}

type HTTPError

type HTTPError struct {
	Code int
	// contains filtered or unexported fields
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

type RPCError

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

func (*RPCError) Error

func (e *RPCError) Error() string

type RPCRequest

type RPCRequest struct {
	JsonRPC string      `json:"jsonrpc"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params"`
	ID      int         `json:"id"`
}

func NewRequest

func NewRequest(method string, params ...interface{}) *RPCRequest

type RPCResponse

type RPCResponse struct {
	JsonRPC string      `json:"jsonrpc"`
	Result  interface{} `json:"result,omitempty"`
	Error   *RPCError   `json:"error,omitempty"`
	ID      int         `json:"id"`
}

func (*RPCResponse) GetObject

func (r *RPCResponse) GetObject(toType interface{}) error

type RPCResponses

type RPCResponses []*RPCResponse

Jump to

Keyboard shortcuts

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