httpclient

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context interface {
	GetStringMapString(string) map[string]string
}

type FileParam

type FileParam struct {
	Key        string
	FileName   string
	FileReader io.Reader
}

type HttpClient

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

func New

func New(setting URLSetting) *HttpClient

New 完全版new,适合修改重试次数时或默认超时时间时

func QuickNew

func QuickNew() *HttpClient

QuickNew 简易版使用,直接请求

func (*HttpClient) Get

func (c *HttpClient) Get(url string, params map[string]string) (res []byte, err error)

func (*HttpClient) GetByRes

func (c *HttpClient) GetByRes(url string, params map[string]string, result interface{}) (response *resty.Response, err error)

func (*HttpClient) PostFile

func (c *HttpClient) PostFile(url string, params map[string]string, files []FileParam) (response *resty.Response, err error)

func (*HttpClient) PostFileByRes

func (c *HttpClient) PostFileByRes(url string, params map[string]string, files []FileParam, result interface{}) (response *resty.Response, err error)

func (*HttpClient) PostForm

func (c *HttpClient) PostForm(url string, params map[string]string) (response *resty.Response, err error)

func (*HttpClient) PostFormByRes

func (c *HttpClient) PostFormByRes(url string, params map[string]string, result interface{}) (response *resty.Response, err error)

func (*HttpClient) PostJson

func (c *HttpClient) PostJson(url string, params interface{}) (response *resty.Response, err error)

func (*HttpClient) PostJsonByRes

func (c *HttpClient) PostJsonByRes(url string, params, result interface{}) (response *resty.Response, err error)

func (*HttpClient) SetCookie

func (c *HttpClient) SetCookie(cookies map[string]string) *HttpClient

func (*HttpClient) SetHeaders

func (c *HttpClient) SetHeaders(headers map[string]string) *HttpClient

func (*HttpClient) SetProxy

func (c *HttpClient) SetProxy(proxyURL string) *HttpClient

type URLSetting

type URLSetting struct {
	RetryCount int           `mapstructure:"retry_count"`
	Timeout    time.Duration `mapstructure:"timeout"`
	// ErrHook 用于用户自定义http调用报错时要做的处理
	ErrHook resty.ErrorHook
}

Jump to

Keyboard shortcuts

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