Documentation
¶
Overview ¶
Package client provides methods to do http GET / POST request.
Index ¶
- func GetDefaultTimeout(slow bool) int
- func HTTPGet(url string, params, headers map[string]string, timeout int) (*http.Response, error)
- func HTTPGetWithContext(ctx context.Context, url string, params, headers map[string]string, ...) (*http.Response, error)
- func HTTPPost(url string, body interface{}, params, headers map[string]string, timeout int) (*http.Response, error)
- func HTTPPostWithContext(ctx context.Context, url string, body interface{}, ...) (*http.Response, error)
- func HTTPRawPost(url, body string, params, headers map[string]string, timeout int) (*http.Response, error)
- func HTTPRawPostWithContext(ctx context.Context, url, body string, params, headers map[string]string, ...) (*http.Response, error)
- func InitHTTPClient()
- func RPCGet(result interface{}, url string) error
- func RPCGetRequest(result interface{}, url string, params, headers map[string]string, timeout int) error
- func RPCGetWithTimeout(result interface{}, url string, timeout int) error
- func RPCPost(result interface{}, url, method string, params ...interface{}) error
- func RPCPostRequest(url string, req *Request, result interface{}) error
- func RPCPostRequestWithContext(ctx context.Context, url string, req *Request, result interface{}) error
- func RPCPostWithContext(ctx context.Context, result interface{}, url, method string, ...) error
- func RPCPostWithTimeout(timeout int, result interface{}, url, method string, params ...interface{}) error
- func RPCPostWithTimeoutAndID(result interface{}, timeout, id int, url, method string, params ...interface{}) error
- func RPCRawGet(url string) (string, error)
- func RPCRawGetRequest(url string, params, headers map[string]string, timeout int) (string, error)
- func RPCRawGetWithTimeout(url string, timeout int) (string, error)
- func RPCRawPost(url, body string) (string, error)
- func RPCRawPostWithTimeout(url, reqBody string, timeout int) (string, error)
- type Request
- type RequestBody
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDefaultTimeout ¶ added in v3.4.0
GetDefaultTimeout get defaule timeout
func HTTPGetWithContext ¶ added in v3.4.0
func HTTPGetWithContext(ctx context.Context, url string, params, headers map[string]string, timeout int) (*http.Response, error)
HTTPGetWithContext http get with context
func HTTPPost ¶
func HTTPPost(url string, body interface{}, params, headers map[string]string, timeout int) (*http.Response, error)
HTTPPost http post
func HTTPPostWithContext ¶ added in v3.4.0
func HTTPPostWithContext(ctx context.Context, url string, body interface{}, params, headers map[string]string, timeout int) (*http.Response, error)
HTTPPostWithContext http post with context
func HTTPRawPost ¶
func HTTPRawPost(url, body string, params, headers map[string]string, timeout int) (*http.Response, error)
HTTPRawPost http raw post
func HTTPRawPostWithContext ¶ added in v3.4.0
func HTTPRawPostWithContext(ctx context.Context, url, body string, params, headers map[string]string, timeout int) (*http.Response, error)
HTTPRawPostWithContext http raw post with context
func RPCGetRequest ¶
func RPCGetRequest(result interface{}, url string, params, headers map[string]string, timeout int) error
RPCGetRequest rpc get request
func RPCGetWithTimeout ¶
RPCGetWithTimeout rpc get with timeout
func RPCPostRequest ¶
RPCPostRequest rpc post request
func RPCPostRequestWithContext ¶ added in v3.4.0
func RPCPostRequestWithContext(ctx context.Context, url string, req *Request, result interface{}) error
RPCPostRequestWithContext rpc post request with context
func RPCPostWithContext ¶ added in v3.4.0
func RPCPostWithContext(ctx context.Context, result interface{}, url, method string, params ...interface{}) error
RPCPostWithContext rpc post with context
func RPCPostWithTimeout ¶ added in v3.4.0
func RPCPostWithTimeout(timeout int, result interface{}, url, method string, params ...interface{}) error
RPCPostWithTimeout rpc post with timeout
func RPCPostWithTimeoutAndID ¶
func RPCPostWithTimeoutAndID(result interface{}, timeout, id int, url, method string, params ...interface{}) error
RPCPostWithTimeoutAndID rpc post with timeout and id
func RPCRawGetRequest ¶
RPCRawGetRequest rpc raw get request
func RPCRawGetWithTimeout ¶
RPCRawGetWithTimeout rpc raw get with timeout
Types ¶
type Request ¶
Request json rpc request
func NewRequest ¶
NewRequest new request
func NewRequestWithTimeoutAndID ¶
NewRequestWithTimeoutAndID new request with timeout and id
type RequestBody ¶
type RequestBody struct {
Version string `json:"jsonrpc"`
Method string `json:"method"`
Params interface{} `json:"params"`
ID int `json:"id"`
}
RequestBody request body