jsonrpc

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(endpoint string, opts ...Option) *Client

func (*Client) Call

func (c *Client) Call(request *Request) (*Response, error)

type Error

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

func (*Error) Error

func (e *Error) Error() string

type Notification

type Notification struct {
	Version string `json:"jsonrpc"`
	Method  string `json:"method"`
	Params  any    `json:"params,omitempty"`
}

type Option

type Option func(o *Client)

func HttpClient

func HttpClient(hc *http.Client) Option

type Request

type Request struct {
	Version string `json:"jsonrpc"`
	Method  string `json:"method"`
	Params  any    `json:"params,omitempty"`
	ID      any    `json:"id"`
}

func NewRequest

func NewRequest[T RequestID](method string, params any, id T) *Request

type RequestID

type RequestID interface {
	~string | ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}

type Response

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

func (*Response) GetAny

func (r *Response) GetAny(v any) error

func (*Response) GetString

func (r *Response) GetString() (string, error)

Jump to

Keyboard shortcuts

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