Documentation
¶
Index ¶
Constants ¶
const ( InvalidParamsErrorCode int = -32602 MethodNotFoundErrorCode int = -32601 InvalidRequestErrorCode int = -32600 ServerErrorCode int = -32000 )
const JSONRPCVersion = "2.0"
Variables ¶
This section is empty.
Functions ¶
func IsValidBaseRequest ¶
func IsValidBaseRequest(baseRequest *BaseJSONRequest) bool
IsValidBaseRequest validates that the base JSON request is valid
Types ¶
type BaseJSON ¶
BaseJSON defines the base JSON fields all JSON-RPC requests and responses need to have
type BaseJSONError ¶
type BaseJSONError struct {
Data any `json:"data,omitempty"`
Message string `json:"message"`
Code int `json:"code"`
}
BaseJSONError defines the base JSON response error format
func GenerateResponseError ¶
func GenerateResponseError(err error) *BaseJSONError
GenerateResponseError generates the JSON-RPC server error response
func NewJSONError ¶
func NewJSONError(message string, code int) *BaseJSONError
NewJSONError creates a new JSON-RPC error
type BaseJSONRequest ¶
type BaseJSONRequest struct {
BaseJSON
Method string `json:"method"`
Params []any `json:"params"`
Meta json.RawMessage `json:"meta"`
}
BaseJSONRequest defines the base JSON request format
func NewJSONRequest ¶
func NewJSONRequest( id uint, method string, params []any, ) *BaseJSONRequest
NewJSONRequest creates a new JSON-RPC request
type BaseJSONRequests ¶
type BaseJSONRequests []*BaseJSONRequest
BaseJSONRequests represents a batch of JSON-RPC requests
func ExtractBaseRequests ¶
func ExtractBaseRequests(requestBody []byte) (BaseJSONRequests, error)
ExtractBaseRequests extracts the base JSON-RPC request from the request body
type BaseJSONResponse ¶
type BaseJSONResponse struct {
Result any `json:"result,omitempty"`
Error *BaseJSONError `json:"error,omitempty"`
BaseJSON
}
BaseJSONResponse defines the base JSON response format
func NewJSONResponse ¶
func NewJSONResponse( id uint, result any, err *BaseJSONError, ) *BaseJSONResponse
NewJSONResponse creates a new JSON-RPC response
type BaseJSONResponses ¶
type BaseJSONResponses []*BaseJSONResponse
BaseJSONResponses represents a batch of JSON-RPC responses