client

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

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 NewHTTPClient

func NewHTTPClient() *HTTPClient

NewHTTPClient 初始化 http 客户端

func NewHTTPTLSClient

func NewHTTPTLSClient() *HTTPClient

NewHTTPTLSClient 初始化 http tls 客户端

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 : 构造请求

func (*HTTPClient) Post

func (c *HTTPClient) Post(endpoint string, data io.Reader, vs ...interface{}) ([]byte, error)

Post : post 方法

func (*HTTPClient) SetTimeout

func (c *HTTPClient) SetTimeout(t time.Duration)

SetTimeout 重置超时时间

type JSONRPCClient

type JSONRPCClient struct {
	Debug bool
	// contains filtered or unexported fields
}

func NewJSONRPCClient

func NewJSONRPCClient() *JSONRPCClient

NewJSONRPCClient 初始化客户端

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

func NewRequest(id interface{}, method string, params []interface{}) (*Request, error)

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.

Jump to

Keyboard shortcuts

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