Documentation
¶
Index ¶
Constants ¶
View Source
const Version = "2.0"
Version is the JSON-RPC protocol version.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
Code int `json:"code"`
Reason string `json:"reason"`
Message string `json:"message"`
Data map[string]string `json:"data,omitempty"`
}
Error represents a JSON-RPC 2.0 error.
type Push ¶
type Push struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Data any `json:"data,omitempty"`
}
Push represents a server-initiated push message (no ID, not tied to a request).
type Request ¶
type Request struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method"`
Params json.RawMessage `json:"params,omitempty"`
ID any `json:"id,omitempty"`
}
Request represents a JSON-RPC 2.0 request.
func (*Request) IsNotification ¶
IsNotification returns true if the request is a notification (no ID).
type Response ¶
type Response struct {
JSONRPC string `json:"jsonrpc"`
Method string `json:"method,omitempty"` // For notifications
Result any `json:"result,omitempty"`
Error *Error `json:"error,omitempty"`
ID any `json:"id,omitempty"`
}
Response represents a JSON-RPC 2.0 response.
func NewErrorResponse ¶
NewErrorResponse creates an error response from an error.
func NewResponse ¶
NewResponse creates a success response.
Click to show internal directories.
Click to hide internal directories.