Documentation ¶
Overview ¶
Package jsonrpcserver allows exposing functions like: func Foo(context, int) (int, error) as a JSON RPC methods
This implementation is similar to the one in go-ethereum, but the idea is to eventually replace it as a default JSON RPC server implementation in Flasbhots projects and for this we need to reimplement some of the quirks of existing API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( CodeParseError = -32700 CodeInvalidRequest = -32600 CodeMethodNotFound = -32601 CodeInvalidParams = -32602 CodeInternalError = -32603 CodeCustomError = -32000 )
View Source
var ( ErrNotFunction = errors.New("not a function") ErrMustReturnError = errors.New("function must return error as a last return value") ErrMustHaveContext = errors.New("function must have context.Context as a first argument") ErrTooManyReturnValues = errors.New("too many return values") ErrTooMuchArguments = errors.New("too much arguments") )
Functions ¶
func GetPriority ¶
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
NewHandler creates JSONRPC http.Handler from the map that maps method names to method functions each method function must: - have context as a first argument - return error as a last argument - have argument types that can be unmarshalled from JSON - have return types that can be marshalled to JSON
type JSONRPCError ¶
type JSONRPCRequest ¶
type JSONRPCRequest struct { JSONRPC string `json:"jsonrpc"` ID any `json:"id"` Method string `json:"method"` Params []json.RawMessage `json:"params"` }
type JSONRPCResponse ¶
type JSONRPCResponse struct { JSONRPC string `json:"jsonrpc"` ID any `json:"id"` Result *json.RawMessage `json:"result,omitempty"` Error *JSONRPCError `json:"error,omitempty"` }
Click to show internal directories.
Click to hide internal directories.