httpclient

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateResponse

func ValidateResponse(actual, expected interface{}) error

ValidateResponse validates the response against expected values Returns nil if validation passes, error otherwise

Types

type Client

type Client struct {
	BaseURL    string
	HTTPClient *http.Client
	RequestID  int
}

Client is a JSON-RPC 2.0 HTTP client

func NewClient

func NewClient(baseURL string, timeout time.Duration) *Client

NewClient creates a new JSON-RPC client

func (*Client) Call

func (c *Client) Call(ctx context.Context, method string, params interface{}) (*Response, error)

Call makes a JSON-RPC 2.0 call

type Error

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

Error represents a JSON-RPC 2.0 error

func (*Error) Error

func (e *Error) Error() string

type Request

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

Request represents a JSON-RPC 2.0 request

type Response

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

Response represents a JSON-RPC 2.0 response

Jump to

Keyboard shortcuts

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