make both Response and Error in one structure

This commit is contained in:
2025-07-29 11:26:26 +03:00
parent a0451aa8a0
commit efbca43f27

View File

@@ -1,27 +1,20 @@
package rpc package rpc
type RPCRequest struct { import "encoding/json"
JSONRPC string `json:"jsonrpc"`
ID any `json:"id"`
Method string `json:"method"`
Params RPCRequestParams `json:"params"`
}
type RPCRequestParams struct { type RPCRequest struct {
ContextVersion string `json:"context-version"` JSONRPC string `json:"jsonrpc"`
Method map[string]any `json:"method-params"` ID *json.RawMessage `json:"id,omitempty"`
Method string `json:"method"`
Params any `json:"params,omitempty"`
ContextVersion string `json:"context-version,omitempty"`
} }
type RPCResponse struct { type RPCResponse struct {
JSONRPC string `json:"jsonrpc"` JSONRPC string `json:"jsonrpc"`
ID any `json:"id"` ID *json.RawMessage `json:"id"`
Result any `json:"result"` Result any `json:"result,omitempty"`
} Error any `json:"error,omitempty"`
type RPCError struct {
JSONRPC string `json:"jsonrpc"`
ID any `json:"id"`
Error any `json:"error"`
} }
const ( const (