Documentation
¶
Index ¶
- Constants
- func GetBody(body interface{}) (buf io.ReadWriter, err error)
- func MakeBatches(elements []interface{}, batchSize int) (batches [][]interface{})
- type HTTPClient
- type HTTPError
- type HTTPErrorHandler
- type Option
- type RPCError
- type RPCRequest
- type RPCRequestMapper
- type RPCRequests
- type RPCResponse
- type RPCResponseRaw
- type Request
- func (r *Request) AddHeader(key, value string)
- func (r *Request) Execute(ctx context.Context, method, url string, body io.Reader, result interface{}) error
- func (r *Request) Get(result interface{}, path string, query url.Values) error
- func (r *Request) GetBase(path string) string
- func (r *Request) GetURL(path string, query url.Values) string
- func (r *Request) Post(result interface{}, path string, body interface{}) error
- func (r *Request) RPCBatchCall(requests RPCRequests) ([]RPCResponse, error)
- func (r *Request) RPCCall(result interface{}, method string, params interface{}) error
- func (r *Request) RPCCallRaw(method string, params interface{}) ([]byte, error)
- func (r *Request) SetProxy(proxyURL string) error
- func (r *Request) SetTimeout(timeout time.Duration)
Constants ¶
View Source
const JSONRPCVersion = "2.0"
Variables ¶
This section is empty.
Functions ¶
func GetBody ¶
func GetBody(body interface{}) (buf io.ReadWriter, err error)
func MakeBatches ¶
func MakeBatches(elements []interface{}, batchSize int) (batches [][]interface{})
Types ¶
type Option ¶
func ProxyOption ¶
func TimeoutOption ¶
TimeoutOption is an option to set timeout for the http client calls value unit is nanoseconds
type RPCRequest ¶
type RPCRequestMapper ¶
type RPCRequestMapper func(interface{}) RPCRequest
type RPCRequests ¶
type RPCRequests []*RPCRequest
func MakeBatchRequests ¶
func MakeBatchRequests(elements []interface{}, batchSize int, mapper RPCRequestMapper) (requests []RPCRequests)
type RPCResponse ¶
type RPCResponse struct {
JSONRPC string `json:"jsonrpc"`
Error *RPCError `json:"error,omitempty"`
Result interface{} `json:"result,omitempty"`
ID int64 `json:"id,omitempty"`
}
func (*RPCResponse) GetObject ¶
func (r *RPCResponse) GetObject(toType interface{}) error
type RPCResponseRaw ¶
type RPCResponseRaw struct {
JSONRPC string `json:"jsonrpc"`
Error *RPCError `json:"error,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
ID int64 `json:"id,omitempty"`
}
type Request ¶
type Request struct {
BaseURL string
Headers map[string]string
HTTPClient HTTPClient
HTTPErrorHandler HTTPErrorHandler
}
func InitClient ¶
func InitClient(baseURL string, errorHandler HTTPErrorHandler, options ...Option) Request
func InitJSONClient ¶
func InitJSONClient(baseURL string, errorHandler HTTPErrorHandler, options ...Option) Request
func (*Request) RPCBatchCall ¶
func (r *Request) RPCBatchCall(requests RPCRequests) ([]RPCResponse, error)
func (*Request) RPCCallRaw ¶
func (*Request) SetTimeout ¶
Click to show internal directories.
Click to hide internal directories.