Documentation ¶
Overview ¶
Package Rpc provides a simple JSON-RPC 2.0 client & server implementation.
Index ¶
Constants ¶
View Source
const ( CodeParseError = -32700 CodeInvalidRequest = -32600 CodeMethodNotFound = -32601 CodeInvalidParams = -32602 CodeInternalError = -32603 CodeServerError = -32000 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represent jsonrpc client object.
type HandlerFunc ¶
type HandlerFunc func(context.Context, json.RawMessage) (json.RawMessage, error)
HandlerFunc represent jsonrpc handler function.
type Request ¶
type Request struct { Jsonrpc string `json:"jsonrpc"` Method string `json:"method"` Params json.RawMessage `json:"params"` Id any `json:"id"` }
Request represent jsonrpc request object.
type Response ¶
type Response struct { Jsonrpc string `json:"jsonrpc"` Result json.RawMessage `json:"result,omitempty"` Error *Error `json:"error,omitempty"` Id any `json:"id"` }
Response represent jsonrpc response object.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represent jsonrpc server object.
func (*Server) Match ¶
Match match the request method with the registered handlers and run the handler.
func (*Server) RegisterService ¶
func (s *Server) RegisterService(method string, handler HandlerFunc)
RegisterService registers a service with the rpc server.
Click to show internal directories.
Click to hide internal directories.