rhttp

package
v0.0.0-...-bac8e5f Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestIdKey = "*req*"
)

Variables

This section is empty.

Functions

func SetApiLog

func SetApiLog(log *rlog.Log)

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

type HTTPClientOption

type HTTPClientOption struct {
	Retry         int
	RetryInterval time.Duration
	CloseLog      bool
	Timeout       time.Duration
	Mock          string
}

HTTPClientOption 配置选项

Jump to

Keyboard shortcuts

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