jsonrpc

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONRPCError

type JSONRPCError struct {
	// Error code
	Code int `json:"code" example:"-32603"`
	// Error message
	Message string `json:"message" example:"Internal error"`
	// Error data
	Data interface{} `json:"data,omitempty" example:"{}"`
}

JSON-RPC 2.0 error https://www.jsonrpc.org/specification#error_object

type JSONRPCRequest

type JSONRPCRequest struct {
	// JSON-RPC version
	Version string `json:"jsonrpc" example:"2.0"`
	// Method name
	Method string `json:"method" example:"method"`
	// Request parameters
	Params interface{} `json:"params,omitempty" example:"{}"`
	// Request ID
	ID interface{} `json:"id,omitempty" example:"1"`
}

JSON-RPC 2.0 request https://www.jsonrpc.org/specification#request_object

func NewJSONRPCNotification

func NewJSONRPCNotification(method string, params interface{}) *JSONRPCRequest

NewJSONRPCNotification creates new JSON-RPC 2.0 notification

func NewJSONRPCRequest

func NewJSONRPCRequest(method string, params interface{}, id interface{}) *JSONRPCRequest

NewJSONRPCRequest creates new JSON-RPC 2.0 request

func ParseHTTPRequest

func ParseHTTPRequest(req *http.Request) (*JSONRPCRequest, error)

ParseHTTPRequest parses JSON-RPC 2.0 request from HTTP request

func ParseRequest

func ParseRequest(data []byte) (*JSONRPCRequest, error)

ParseRequest parses JSON-RPC 2.0 request from JSON string

type JSONRPCResponse

type JSONRPCResponse struct {
	// JSON-RPC version
	Version string `json:"jsonrpc" example:"2.0"`
	// Result of the method call
	Result interface{} `json:"result,omitempty" example:"{}"`
	// Error object
	Error *JSONRPCError `json:"error,omitempty"`
	// Request ID
	ID interface{} `json:"id,omitempty" example:"1"`
}

JSON-RPC 2.0 response https://www.jsonrpc.org/specification#response_object

func NewJSONRPCError

func NewJSONRPCError(id interface{}, code int, message string, data interface{}) *JSONRPCResponse

NewJSONRPCError creates new JSON-RPC 2.0 error

func NewJSONRPCResponse

func NewJSONRPCResponse(id interface{}, result interface{}) *JSONRPCResponse

NewJSONRPCResponse creates new JSON-RPC 2.0 response

func ParseResponse

func ParseResponse(data []byte) (*JSONRPCResponse, error)

ParseResponse parses JSON-RPC 2.0 response from JSON string

Jump to

Keyboard shortcuts

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