httpclient

package
v0.0.0-...-736094d Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = NewClient()

Functions

This section is empty.

Types

type FormFile

type FormFile string

type GetOrDeleteExecutor

type GetOrDeleteExecutor struct {
	// contains filtered or unexported fields
}

func (*GetOrDeleteExecutor) AddHeader

func (r *GetOrDeleteExecutor) AddHeader(name string, value interface{}) *GetOrDeleteExecutor

设置请求头

func (*GetOrDeleteExecutor) AddParameter

func (r *GetOrDeleteExecutor) AddParameter(name string, value interface{}) *GetOrDeleteExecutor

设置查询参数

func (*GetOrDeleteExecutor) AddParameters

func (r *GetOrDeleteExecutor) AddParameters(values H) *GetOrDeleteExecutor

设置查询参数

func (*GetOrDeleteExecutor) AddRetryConditionFunc

func (r *GetOrDeleteExecutor) AddRetryConditionFunc(_retryCondition RetryConditionFunc) *GetOrDeleteExecutor

添加重试条件

func (*GetOrDeleteExecutor) Do

func (r *GetOrDeleteExecutor) Do() (*http.Response, error)

执行请求

func (*GetOrDeleteExecutor) DoForEntity

func (r *GetOrDeleteExecutor) DoForEntity() (*RespondEntity, error)

func (*GetOrDeleteExecutor) DoForString

func (r *GetOrDeleteExecutor) DoForString() (string, error)

func (*GetOrDeleteExecutor) SetExpectStatus

func (r *GetOrDeleteExecutor) SetExpectStatus(expect int) *GetOrDeleteExecutor

设置预期请求状态

func (*GetOrDeleteExecutor) SetHeaders

func (r *GetOrDeleteExecutor) SetHeaders(values H) *GetOrDeleteExecutor

设置请求头

func (*GetOrDeleteExecutor) SetRetryCount

func (r *GetOrDeleteExecutor) SetRetryCount(_retryCount int) *GetOrDeleteExecutor

设置重试次数

func (*GetOrDeleteExecutor) SetRetryInterval

func (r *GetOrDeleteExecutor) SetRetryInterval(_retryInterval int) *GetOrDeleteExecutor

设置重试间隔时间,单位为秒

type H

type H map[string]interface{}

参数

type HttpClient

type HttpClient struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient() *HttpClient

创建Client

func (*HttpClient) AddHeader

func (c *HttpClient) AddHeader(key string, val string) *HttpClient

添加请求头

func (*HttpClient) AddHeaders

func (c *HttpClient) AddHeaders(values H) *HttpClient

添加请求头

func (*HttpClient) AddRetryConditionFunc

func (c *HttpClient) AddRetryConditionFunc(retryCondition RetryConditionFunc) *HttpClient

添加重试条件

func (*HttpClient) DELETE

func (c *HttpClient) DELETE(url string) *GetOrDeleteExecutor

Delete请求

func (*HttpClient) GET

func (c *HttpClient) GET(url string) *GetOrDeleteExecutor

Get请求

func (*HttpClient) GetRetryCount

func (c *HttpClient) GetRetryCount() int

获取重试次数

func (*HttpClient) GetRetryInterval

func (c *HttpClient) GetRetryInterval() int

获取重试间隔时间

func (*HttpClient) GetTimeout

func (c *HttpClient) GetTimeout() int

获取超时时间

func (*HttpClient) POST

func (c *HttpClient) POST(url string) *PostOrPutExecutor

Post请求

func (*HttpClient) PUT

func (c *HttpClient) PUT(url string) *PostOrPutExecutor

Put请求

func (*HttpClient) SetLogger

func (c *HttpClient) SetLogger(logger *zap.Logger)

func (*HttpClient) SetRetryCount

func (c *HttpClient) SetRetryCount(retryCount int) *HttpClient

设置重试次数

func (*HttpClient) SetRetryInterval

func (c *HttpClient) SetRetryInterval(retryInterval int) *HttpClient

设置重试间隔时间,单位为秒

func (*HttpClient) SetTimeout

func (c *HttpClient) SetTimeout(timeout int) *HttpClient

设置超时时间,单位为秒

func (*HttpClient) SetTransport

func (c *HttpClient) SetTransport(transport http.RoundTripper) *HttpClient

设置Transport (用于确定HTTP请求的创建机制) 如果为空,将会使用DefaultTransport

type PostOrPutExecutor

type PostOrPutExecutor struct {
	// contains filtered or unexported fields
}

func (*PostOrPutExecutor) AddHeader

func (r *PostOrPutExecutor) AddHeader(name string, value interface{}) *PostOrPutExecutor

设置请求头

func (*PostOrPutExecutor) AddRetryConditionFunc

func (r *PostOrPutExecutor) AddRetryConditionFunc(_retryCondition RetryConditionFunc) *PostOrPutExecutor

添加重试条件

func (*PostOrPutExecutor) Do

func (r *PostOrPutExecutor) Do() (*http.Response, error)

执行请求

func (*PostOrPutExecutor) DoForEntity

func (r *PostOrPutExecutor) DoForEntity() (*RespondEntity, error)

func (*PostOrPutExecutor) DoForString

func (r *PostOrPutExecutor) DoForString() (string, error)

func (*PostOrPutExecutor) SetBodyAsForm

func (r *PostOrPutExecutor) SetBodyAsForm(body H) *PostOrPutExecutor

func (*PostOrPutExecutor) SetBodyAsJson

func (r *PostOrPutExecutor) SetBodyAsJson(body interface{}) *PostOrPutExecutor

设置请求的contentType 为: "application/json"

func (*PostOrPutExecutor) SetExpectStatus

func (r *PostOrPutExecutor) SetExpectStatus(expect int) *PostOrPutExecutor

设置预期请求状态

func (*PostOrPutExecutor) SetHeaders

func (r *PostOrPutExecutor) SetHeaders(values H) *PostOrPutExecutor

设置请求头

func (*PostOrPutExecutor) SetRetryCount

func (r *PostOrPutExecutor) SetRetryCount(_retryCount int) *PostOrPutExecutor

设置重试次数

func (*PostOrPutExecutor) SetRetryInterval

func (r *PostOrPutExecutor) SetRetryInterval(_retryInterval int) *PostOrPutExecutor

设置重试间隔时间,单位为秒

type RespondEntity

type RespondEntity struct {
	// contains filtered or unexported fields
}

应答实体

func (*RespondEntity) Data

func (t *RespondEntity) Data() []byte

func (*RespondEntity) DataAsString

func (t *RespondEntity) DataAsString() string

func (*RespondEntity) StatusCode

func (t *RespondEntity) StatusCode() int

func (*RespondEntity) StatusText

func (t *RespondEntity) StatusText() string

func (*RespondEntity) Unmarshal

func (t *RespondEntity) Unmarshal(entity interface{}) error

type RetryConditionFunc

type RetryConditionFunc func(*http.Response) bool

重试条件

Jump to

Keyboard shortcuts

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