client

package
v0.3.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 15, 2021 License: GPL-3.0 Imports: 11 Imported by: 3

Documentation

Overview

Package client provides methods to do http GET / POST request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTTPGet

func HTTPGet(url string, params, headers map[string]string, timeout int) (*http.Response, error)

HTTPGet http get

func HTTPPost

func HTTPPost(url string, body interface{}, params, headers map[string]string, timeout int) (*http.Response, error)

HTTPPost http post

func HTTPRawPost

func HTTPRawPost(url, body string, params, headers map[string]string, timeout int) (*http.Response, error)

HTTPRawPost http raw post

func InitHTTPClient

func InitHTTPClient()

InitHTTPClient init http client

func RPCGet

func RPCGet(result interface{}, url string) error

RPCGet rpc get

func RPCGetRequest

func RPCGetRequest(result interface{}, url string, params, headers map[string]string, timeout int) error

RPCGetRequest rpc get request

func RPCGetWithTimeout

func RPCGetWithTimeout(result interface{}, url string, timeout int) error

RPCGetWithTimeout rpc get with timeout

func RPCPost

func RPCPost(result interface{}, url, method string, params ...interface{}) error

RPCPost rpc post

func RPCPostRequest

func RPCPostRequest(url string, req *Request, result interface{}) error

RPCPostRequest rpc post request

func RPCPostWithTimeout added in v0.3.8

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 RPCRawGet

func RPCRawGet(url string) (string, error)

RPCRawGet rpc raw get

func RPCRawGetRequest

func RPCRawGetRequest(url string, params, headers map[string]string, timeout int) (string, error)

RPCRawGetRequest rpc raw get request

func RPCRawGetWithTimeout

func RPCRawGetWithTimeout(url string, timeout int) (string, error)

RPCRawGetWithTimeout rpc raw get with timeout

func RPCRawPost

func RPCRawPost(url, body string) (string, error)

RPCRawPost rpc raw post

func RPCRawPostWithTimeout

func RPCRawPostWithTimeout(url, reqBody string, timeout int) (string, error)

RPCRawPostWithTimeout rpc raw post with timeout

Types

type Request

type Request struct {
	Method  string
	Params  interface{}
	Timeout int
	ID      int
}

Request json rpc request

func NewRequest

func NewRequest(method string, params ...interface{}) *Request

NewRequest new request

func NewRequestWithTimeoutAndID

func NewRequestWithTimeoutAndID(timeout, id int, method string, params ...interface{}) *Request

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL