httpclient

package
v0.0.23 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HeadContentType = "content-type"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ChooseProxy added in v0.0.21

type ChooseProxy interface {
	// Choose 选择代理
	Choose(all []string) string
}

ChooseProxy 多代理模式下的选择代理策略

type ContentType

type ContentType string
const (
	ContentTypeJson ContentType = "application/json"
)

type RestyClient

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

RestyClient resty客户端

func NewRestyClient

func NewRestyClient(proxyHttpHost ...string) *RestyClient

NewRestyClient 创建一个httpClient对象 proxyHttpHost 可以指定代理 如 localhost:7890

func NewRestyClientWithMultiProxy added in v0.0.21

func NewRestyClientWithMultiProxy(multiProxy []string, choose ...ChooseProxy) *RestyClient

NewRestyClientWithMultiProxy 创建一个多代理实例,该实例下的请求将通过策略通过代理

func (*RestyClient) DisableTLSVerify added in v0.0.21

func (r *RestyClient) DisableTLSVerify() *RestyClient

func (*RestyClient) R

func (r *RestyClient) R() *RestyRequest

R 获取Request实例

func (*RestyClient) RawRestyClient added in v0.0.21

func (r *RestyClient) RawRestyClient() *resty.Client

RawRestyClient 获取原始restyClient实例

func (*RestyClient) SetBaseUrl

func (r *RestyClient) SetBaseUrl(baseUrl string) *RestyClient

SetBaseUrl 设置BaseUrl

func (*RestyClient) SetHeader

func (r *RestyClient) SetHeader(key, value string) *RestyClient

SetHeader 设置请求头

func (*RestyClient) SetHeaders

func (r *RestyClient) SetHeaders(headers map[string]string) *RestyClient

SetHeaders 设置请求头

func (*RestyClient) SetProxy added in v0.0.21

func (r *RestyClient) SetProxy(proxy string) *RestyClient

SetProxy 设置代理

func (*RestyClient) SetTimeout

func (r *RestyClient) SetTimeout(timeout time.Duration) *RestyClient

SetTimeout 设置超时时间

type RestyMethod

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

RestyMethod resty请求方法对象

func (*RestyMethod) E

func (m *RestyMethod) E() (*resty.Response, error)

E Execution

func (*RestyMethod) SetBodyForm

func (m *RestyMethod) SetBodyForm(formEncode map[string]string) *RestyMethod

func (*RestyMethod) SetBodyJson

func (m *RestyMethod) SetBodyJson(bodyJson *string) *RestyMethod

func (*RestyMethod) SetRequestBody

func (m *RestyMethod) SetRequestBody(bodyString *string, contentType ContentType) *RestyMethod

type RestyRequest

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

RestyRequest resty请求对象

func (*RestyRequest) Get

func (r *RestyRequest) Get(url string) (*resty.Response, error)

func (*RestyRequest) M

func (r *RestyRequest) M(httpMethod string, url string) *RestyMethod

M set Method

func (*RestyRequest) Post

func (r *RestyRequest) Post(url string) (*resty.Response, error)

func (*RestyRequest) PostForm

func (r *RestyRequest) PostForm(url string, formEncode map[string]string) (*resty.Response, error)

func (*RestyRequest) PostJson

func (r *RestyRequest) PostJson(url string, jsonString string) (*resty.Response, error)

func (*RestyRequest) SetDownloadFile added in v0.0.22

func (r *RestyRequest) SetDownloadFile(filepath string) *RestyRequest

SetDownloadFile 将原始内容下载为文件 filepath 文件完整路径(含文件名)

func (*RestyRequest) SetHeader

func (r *RestyRequest) SetHeader(key, value string) *RestyRequest

func (*RestyRequest) SetHeaders

func (r *RestyRequest) SetHeaders(headers map[string]string) *RestyRequest

func (*RestyRequest) SetPathValues

func (r *RestyRequest) SetPathValues(pathParams map[string]string) *RestyRequest

func (*RestyRequest) SetQueryValues

func (r *RestyRequest) SetQueryValues(any interface{}) *RestyRequest

func (*RestyRequest) SetReturnStruct

func (r *RestyRequest) SetReturnStruct(any interface{}) *RestyRequest

SetReturnStruct 使用默认响应Body内容与结构体绑定 仅支持响应码 200 - 299 内容类型为 JSON or XML时

func (*RestyRequest) WithContext

func (r *RestyRequest) WithContext(ctx context.Context) *RestyRequest

Jump to

Keyboard shortcuts

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