mirror of
https://github.com/akyaiy/GoSally-mvp.git
synced 2026-01-03 17:32:25 +00:00
make both Response and Error in one structure
This commit is contained in:
@@ -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 (
|
||||||
|
|||||||
Reference in New Issue
Block a user