Documentation
¶
Index ¶
- Constants
- type Engine
- func (engine *Engine) ProcessRequest(requestData []byte) []byte
- func (engine *Engine) ProcessRequestDirect(request *Request) *Response
- func (engine *Engine) RegisterMethod(name string, handler MethodHandler)
- func (engine *Engine) RegisteredMethods() []string
- func (engine *Engine) SetLogger(logger *slog.Logger)
- type ErrorDetails
- type MethodHandler
- type Request
- type Response
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) 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.
func (*Engine) RegisteredMethods ¶ added in v0.33.0
RegisteredMethods returns a sorted list of registered method names.
type ErrorDetails ¶
type ErrorDetails struct {
Code int `json:"code"`
Message string `json:"message"`
Data any `json:"data,omitempty"`
}
ErrorDetails represents a JSON-RPC 2.0 error object.
type MethodHandler ¶
MethodHandler defines the signature for JSON-RPC method handlers.
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params any `json:"params,omitempty"`
ID any `json:"id,omitempty"`
// contains filtered or unexported fields
}
Request represents a JSON-RPC 2.0 request message.
func (*Request) IsNotification ¶ added in v1.1.0
IsNotification reports whether this request omitted the id member.
func (*Request) UnmarshalJSON ¶ added in v1.1.0
UnmarshalJSON preserves whether "id" was present. JSON-RPC notifications omit id entirely; an explicit `"id": null` is still a request and must get a response with a null id.