Documentation
¶
Index ¶
Constants ¶
const ( ErrorCodeParseError = -32700 ErrorCodeInvalidRequest = -32600 ErrorCodeMethodNotFound = -32601 ErrorCodeInvalidParams = -32602 ErrorCodeInternalError = -32603 )
Standard JSON-RPC error codes.
const Version = "2.0"
Version is the JSON-RPC 2.0 version identifier.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine handles JSON-RPC 2.0 request processing.
func (*Engine) GetRegisteredMethods ¶
GetRegisteredMethods returns a sorted list of registered method names.
func (*Engine) ProcessRequest ¶
ProcessRequest processes a JSON-RPC request payload and returns a response payload.
func (*Engine) ProcessRequestDirect ¶
ProcessRequestDirect processes a JSON-RPC request object and returns the response object.
func (*Engine) RegisterMethod ¶
func (engine *Engine) RegisterMethod(name string, handler MethodHandler)
RegisterMethod registers a method handler with the JSON-RPC engine.
type ErrorDetails ¶
type ErrorDetails struct {
Code int `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data,omitempty"`
}
ErrorDetails represents a JSON-RPC 2.0 error object.
type MethodHandler ¶
type MethodHandler func(params interface{}) (interface{}, error)
MethodHandler defines the signature for JSON-RPC method handlers.
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params interface{} `json:"params,omitempty"`
ID interface{} `json:"id,omitempty"`
}
Request represents a JSON-RPC 2.0 request message.
type Response ¶
type Response struct {
JSONRPC string `json:"jsonrpc"`
Result interface{} `json:"result,omitempty"`
Error *ErrorDetails `json:"error,omitempty"`
ID interface{} `json:"id"`
}
Response represents a JSON-RPC 2.0 response message.