suirpc

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetClient added in v0.0.6

func SetClient(client *resty.Client)

func SetDebugMode added in v0.0.6

func SetDebugMode(enable bool)

Types

type RpcError

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

RpcError represents a JSON-RPC error-info.

func (*RpcError) Error

func (rpcError *RpcError) Error() string

Error implement the error interface{} to return wrong-reason

type RpcRequest

type RpcRequest struct {
	Jsonrpc string `json:"jsonrpc"`
	Method  string `json:"method"`
	Params  []any  `json:"params"`
	ID      int    `json:"id"`
}

RpcRequest represents a JSON-RPC request.

type RpcResponse

type RpcResponse[RES any] struct {
	Jsonrpc string    `json:"jsonrpc"`
	ID      int       `json:"id"`
	Result  RES       `json:"result"`
	Error   *RpcError `json:"error,omitempty"`
}

RpcResponse represents a JSON-RPC response.

func SendRpc

func SendRpc[RES any](ctx context.Context, serverUrl string, request *RpcRequest) (rpcResponse *RpcResponse[RES], err error)

Jump to

Keyboard shortcuts

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