Documentation ¶
Index ¶
Constants ¶
View Source
const (
// Version is JSON-RPC 2.0 version string.
Version = "2.0"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler func(w ResponseWriter, r *Request) error
Handler represents jsonrpc handler.
if your handler return any error, and you don`t use SetInvalidRequestParamsError() response will have code -32603 and message "Internal error"
if you use SetInvalidRequestParamsError() response will have code -32602 and message "Invalid params"
type Request ¶
type Request struct { Version string `json:"jsonrpc"` Method string `json:"method"` Params json.RawMessage `json:"params"` ID interface{} `json:"id"` // contains filtered or unexported fields }
Request represents a JSON-RPC request received by the server.
type ResponseWriter ¶
type ResponseWriter interface { // SetResponse set response result. SetResponse(v interface{}) // SetErrorData set response error data. // Error will have -32603 status code and message equal to "Internal error". SetErrorData(v interface{}) // SetInvalidRequestParamsError set response error to invalid req params. // Error will have -32602 status code and message equal to "Invalid params". SetInvalidRequestParamsError(data interface{}) }
ResponseWriter represents JSON-RPC response writer interface.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.