jsonrpc

package
v0.395.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// JSON-RPC spec compliant error codes
	JsonRpcParseErrorCode     = -32700
	JsonRpcInvalidRequestCode = -32600
	JsonRpcMethodNotFoundCode = -32601
	JsonRpcInvalidParams      = -32602
	JsonRpcInternalErrorCode  = -32603
	JsonRpcUnauthorized       = -32001 // Not part of the official spec
	JsonRpcForbidden          = -32003 // Not part of the official spec
)

Variables

This section is empty.

Functions

func NewErrorResponse added in v0.368.0

func NewErrorResponse(ctx context.Context, requestId *string, err error) common.Response

func NewHandler

func NewHandler(schema *proto.Schema, api *proto.Api) common.HandlerFunc

func NewSuccessResponse added in v0.368.0

func NewSuccessResponse(ctx context.Context, requestId string, response any, meta *common.ResponseMetadata) common.Response

Types

type JsonRpcError

type JsonRpcError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Detail  any    `json:"detail,omitempty"`
}

type JsonRpcErrorResponse

type JsonRpcErrorResponse struct {
	JsonRpc string       `json:"jsonrpc"`
	ID      *string      `json:"id"`
	Error   JsonRpcError `json:"error"`
}

type JsonRpcRequest

type JsonRpcRequest struct {
	JsonRpc string         `json:"jsonrpc"`
	ID      string         `json:"id"`
	Method  string         `json:"method"`
	Params  map[string]any `json:"params"`
}

func (JsonRpcRequest) Valid

func (r JsonRpcRequest) Valid() bool

type JsonRpcSuccessResponse

type JsonRpcSuccessResponse struct {
	JsonRpc string `json:"jsonrpc"`
	ID      string `json:"id"`
	Result  any    `json:"result"`
}

Jump to

Keyboard shortcuts

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