Documentation ¶
Index ¶
Constants ¶
const (
// ErrCodeServer indicates that client could not unmarshal response from server.
ErrCodeParseError = -32700
)
Variables ¶
This section is empty.
Functions ¶
func WithHttpClient ¶
func WithHttpClient(httpClient HTTPClient) clientOption
WithHttpClient is an option which sets http client implementation for jsonrpc2 client.
Types ¶
type Client ¶
type Client interface {
Call(ctx context.Context, methodName string, params interface{}, result interface{}) error
}
Client represents jsonrpc caller interface. It have only one method call which satisfies simple case of jsonrpc2 usage.
type HTTPClient ¶
HTTPClient is a convenient interface for http worker. It allows to use a custom http transport level implementation.
func NewHttpClient ¶
func NewHttpClient(c *http.Client) HTTPClient
NewHttpClient returns wiring of standard http.Client.
type Request ¶
type Request struct { Version string `json:"jsonrpc"` Method string `json:"method"` Params interface{} `json:"params"` Id uint64 `json:"id"` }
Request represents a jsonrpc2 request.
func (Request) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (Request) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*Request) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Request) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
type Response ¶
type Response struct { Version string `json:"jsonrpc"` Result *json.RawMessage `json:"result"` Error *json.RawMessage `json:"error"` }
Request represents a jsonrpc2 response.
func (Response) MarshalEasyJSON ¶
MarshalEasyJSON supports easyjson.Marshaler interface
func (Response) MarshalJSON ¶
MarshalJSON supports json.Marshaler interface
func (*Response) UnmarshalEasyJSON ¶
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*Response) UnmarshalJSON ¶
UnmarshalJSON supports json.Unmarshaler interface
type ResponseError ¶
type ResponseError struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data"` }
ResponseError is a struct which represents a typical jsonrpc2 error according to specification.
func (*ResponseError) Error ¶
func (e *ResponseError) Error() string
Error returns an error message of ResponseError.
func (ResponseError) MarshalEasyJSON ¶
func (v ResponseError) MarshalEasyJSON(w *jwriter.Writer)
MarshalEasyJSON supports easyjson.Marshaler interface
func (ResponseError) MarshalJSON ¶
func (v ResponseError) MarshalJSON() ([]byte, error)
MarshalJSON supports json.Marshaler interface
func (*ResponseError) UnmarshalEasyJSON ¶
func (v *ResponseError) UnmarshalEasyJSON(l *jlexer.Lexer)
UnmarshalEasyJSON supports easyjson.Unmarshaler interface
func (*ResponseError) UnmarshalJSON ¶
func (v *ResponseError) UnmarshalJSON(data []byte) error
UnmarshalJSON supports json.Unmarshaler interface