httpclient

package
v0.0.0-...-258923f Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Body

type Body string

Body is an option used for RequestClientOptions

type ContentType

type ContentType string

ContentType is an option used for RequestClientOptions

type Cookies

type Cookies []*http.Cookie

Cookies is an option used for RequestClientOptions

type HcError

type HcError struct {
	Error string
}

type HeaderMap

type HeaderMap map[string]string

HeaderMap is an option used for RequestClientOptions

type HttpClient

type HttpClient struct {
	RequestConfig

	Error error
	// contains filtered or unexported fields
}

func (*HttpClient) DownloadFile

func (hc *HttpClient) DownloadFile(filePath, fileName string) *HttpClient

DownloadFile *

  • @Description: 下载文件
  • @receiver hc
  • @param filePath 文件保存地址
  • @param fileName 文件名
  • @return *HttpClient

func (*HttpClient) GetBytes

func (hc *HttpClient) GetBytes(body *[]byte) *HttpClient

GetBytes *

  • @Description: 获取Bytes
  • @receiver hc
  • @param body
  • @return *HttpClient

func (*HttpClient) GetMap

func (hc *HttpClient) GetMap(m map[string]interface{}) *HttpClient

GetMap *

  • @Description: 获取Map
  • @receiver hc
  • @param m
  • @return *HttpClient

func (*HttpClient) GetString

func (hc *HttpClient) GetString(str *string) *HttpClient

GetString *

  • @Description: 获取字符串
  • @receiver hc
  • @param str
  • @return *HttpClient

func (*HttpClient) GetStruct

func (hc *HttpClient) GetStruct(data interface{}) *HttpClient

GetStruct *

  • @Description: 将结果保存到结构体
  • @receiver hc
  • @param data
  • @return *HttpClient

func (*HttpClient) Retry

func (hc *HttpClient) Retry(retry int, retryInterval []int) *HttpClient

Retry *

  • @Description: 重试
  • @receiver hc
  • @param retry 重试次数
  • @param retryInterval 每次重试之间的间隔(如:[2,2,2,2,2]、[1,2,3,4,5])
  • @return *HttpClient

func (*HttpClient) SaveReturnBizData

func (hc *HttpClient) SaveReturnBizData(result interface{})

SaveReturnBizData *

  • @Description: 保存业务
  • @receiver hc
  • @param result

type QueryMap

type QueryMap map[string]string

QueryMap is an option used for RequestClientOptions

type RequestClientOptions

type RequestClientOptions interface {
	// contains filtered or unexported methods
}

type RequestClientPr

type RequestClientPr struct {
	ContentType string // ContentType
	Body        string // RequestBody
	TableName   string
	QueryMap    map[string]string
	HeaderMap   map[string]string
	Cookies     []*http.Cookie
	SplitTable  bool
}

type RequestConfig

type RequestConfig struct {
	TimeOut            int      // 超时时间
	DB                 *gorm.DB // 数据库对象
	InsecureSkipVerify bool     // InsecureSkipVerify为true,client将不再对服务端的证书进行校验
	// contains filtered or unexported fields
}

func (*RequestConfig) NewHttpClient

func (rc *RequestConfig) NewHttpClient() *http.Client

NewHttpClient *

  • @Description: 创建Http连接池
  • @receiver rc
  • @return *http.Client

func (*RequestConfig) Request

func (rc *RequestConfig) Request(urlPath, method string, data interface{}, rcd *clientmod.HttpRequestRcd, opts ...RequestClientOptions) (hc *HttpClient)

Request *

  • @Description: 创建请求
  • @receiver rc
  • @param url
  • @param method
  • @param data

type SplitTable

type SplitTable bool

SplitTable is an option used for RequestClientOptions

type TableName

type TableName string

TableName is an option used for RequestClientOptions

Jump to

Keyboard shortcuts

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