Documentation ¶
Index ¶
- Constants
- func SetApiLog(log *rlog.Log)
- type HTTPClient
- func (c HTTPClient) Get(urlstr string, body interface{}, header map[string]string) (*http.Response, error)
- func (c HTTPClient) Post(urlstr string, body interface{}, header map[string]string) (*http.Response, error)
- func (c HTTPClient) PostJSON(urlstr string, data interface{}, header map[string]string) (*http.Response, error)
- func (c HTTPClient) PostMultipart(urlstr string, body interface{}, header map[string]string) (*http.Response, error)
- type HTTPClientOption
Constants ¶
View Source
const (
RequestIdKey = "*req*"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient struct
func NewHTTPClient ¶
func NewHTTPClient(ctx context.Context, topic string, option *HTTPClientOption, httpclient *http.Client) *HTTPClient
func (HTTPClient) Get ¶
func (c HTTPClient) Get(urlstr string, body interface{}, header map[string]string) (*http.Response, error)
Get method body 内容可以为一下数据结构 url.Values,map[string]string, map[string][string]
func (HTTPClient) Post ¶
func (c HTTPClient) Post(urlstr string, body interface{}, header map[string]string) (*http.Response, error)
Post method body 如果传入内容 url.Values,map[string]string, map[string][string] 那么将按照Content-Type=application/x-www-form-urlencoded 进行请求 如果body实体中含有文件,那么Content-Type=multipart/form-data 传输 如果body 实体为 string,[]byte,io.Reader 那么直接进行post请求,额外的需要自定义content-type
func (HTTPClient) PostJSON ¶
func (c HTTPClient) PostJSON(urlstr string, data interface{}, header map[string]string) (*http.Response, error)
PostJSON method
func (HTTPClient) PostMultipart ¶
func (c HTTPClient) PostMultipart(urlstr string, body interface{}, header map[string]string) (*http.Response, error)
PostMultipart method
Click to show internal directories.
Click to hide internal directories.