Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(args *RequestArgs) error
Delete 发送Delete请求 注意:发送Delete请求的时候,不要使用Params携带参数,统一放置到Body中,否则远程可能收不到数据
Types ¶
type HTTPClient ¶
type HTTPClient struct { // EnableHTTPS 是否启用HTTPS EnableHTTPS bool // TLSConfig 使用HTTPS的配置 TLSConfig *tls.Config // ConnectTimeout 连接超时 ConnectTimeout time.Duration // RWTimeout 读写超时 RWTimeout time.Duration // Retry 请求重试次数 Retry int // Debug 调试信息写入 Debug logWriter }
func DefaultHTTPClient ¶
func DefaultHTTPClient() *HTTPClient
func (*HTTPClient) Delete ¶
func (c *HTTPClient) Delete(args *RequestArgs) error
func (*HTTPClient) Get ¶
func (c *HTTPClient) Get(args *RequestArgs) error
func (*HTTPClient) Head ¶
func (c *HTTPClient) Head(args *RequestArgs) error
func (*HTTPClient) Post ¶
func (c *HTTPClient) Post(args *RequestArgs) error
func (*HTTPClient) Put ¶
func (c *HTTPClient) Put(args *RequestArgs) error
type RequestArgs ¶
type RequestArgs struct { // URL 请求地址 (必填) URL string // Headers HTTP请求头设置 (可选) // nil表示不设置请求头 Headers map[string]string // Params HTTP请求参数,键值对 (可选) Params map[string]string // Body HTTP请求体设置,必须是struct或[]byte类型 (可选) // nil表示无请求体 Body interface{} // Filters 请求过滤器,会在请求发出前依次调用 Filters []FilterFunc // JSONResult 接收JSON格式的响应内容, 必须是strcut类型 (可选) // 如果该字段非空,将自动解析至JSONResult JSONResult interface{} // BytesResult 接收字节流响应内容 (可选) // 如果该字段非空,响应体内容将被写入BytesResult BytesResult *bytes.Buffer }
RequestArgs 通用请求参数封装
Click to show internal directories.
Click to hide internal directories.