Documentation ¶
Index ¶
- type HTTPClient
- func (c *HTTPClient) Get(endpoint string, vs ...interface{}) ([]byte, error)
- func (c *HTTPClient) MakeGetURL(endpoint string, args map[string]string) string
- func (c *HTTPClient) MakeRequest(ctx context.Context, method, endpoint string, data io.Reader, vs []interface{}) (*http.Request, error)
- func (c *HTTPClient) Post(endpoint string, data io.Reader, vs ...interface{}) ([]byte, error)
- func (c *HTTPClient) SetTimeout(t time.Duration)
- type JSONRPCClient
- type Request
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPClient ¶
type HTTPClient struct { Debug bool // contains filtered or unexported fields }
var Client *HTTPClient
func (*HTTPClient) Get ¶
func (c *HTTPClient) Get(endpoint string, vs ...interface{}) ([]byte, error)
Get : get 方法, 之后可以增加重试
func (*HTTPClient) MakeGetURL ¶
func (c *HTTPClient) MakeGetURL(endpoint string, args map[string]string) string
MakeGetURL : 拼接 url
func (*HTTPClient) MakeRequest ¶
func (c *HTTPClient) MakeRequest(ctx context.Context, method, endpoint string, data io.Reader, vs []interface{}) (*http.Request, error)
MakeRequest : 构造请求
type JSONRPCClient ¶
type JSONRPCClient struct { Debug bool // contains filtered or unexported fields }
func (*JSONRPCClient) Post ¶
func (c *JSONRPCClient) Post(endpoint string, request *Request, username, password string) ([]byte, error)
Post : post 方法
func (*JSONRPCClient) SetTimeout ¶
func (c *JSONRPCClient) SetTimeout(t time.Duration)
SetTimeout 重置超时时间
type Request ¶
type Request struct { JSONRPC string `json:"jsonrpc"` Method string `json:"method"` Params []json.RawMessage `json:"params"` ID interface{} `json:"id"` }
func NewRequest ¶
NewRequest returns a new JSON-RPC 1.0 request object given the provided id, method, and parameters. The parameters are marshaled into a json.RawMessage for the Params field of the returned request object. This function is only provided in case the caller wants to construct raw requests for some reason.
Typically callers will instead want to create a registered concrete command type with the NewCmd or New<Foo>Cmd functions and call the MarshalCmd function with that command to generate the marshaled JSON-RPC request.
Click to show internal directories.
Click to hide internal directories.