Documentation ¶
Index ¶
- Constants
- type BodyMap
- type HttpCli
- func (h *HttpCli) Get(url string) (*HttpCliResp, error)
- func (h *HttpCli) GetHeader(key string) string
- func (h *HttpCli) HeaderIsExist(key string) bool
- func (h *HttpCli) Post(url string, body []byte, contentType ...string) (*HttpCliResp, error)
- func (h *HttpCli) PostForHttpCliBodyer(url string, body httpCliBodyer) (*HttpCliResp, error)
- func (h *HttpCli) ReGet(url string, maxCount ...int) (*HttpCliResp, error)
- func (h *HttpCli) SetHeader(key, value string)
- type HttpCliJsonBody
- type HttpCliResp
- type HttpCliXmlBody
- type HttpClientOption
Constants ¶
View Source
const ( ContentTypeJson = "application/json" ContentTypeXml = "application/xml" ContentTypeProtobuf = "application/octet-stream" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BodyMap ¶
type BodyMap map[string]interface{}
通用请求/响应(不需要结果的)参数 map
func NewBodyMap ¶
func (BodyMap) GetFormatJsonForPrint ¶
获取格式化后的 json, 用于打印
type HttpCli ¶
type HttpCli struct {
// contains filtered or unexported fields
}
HttpCli 会自己释放 Response.Body 并发安全由外部控制
func NewHttpCli ¶
func NewHttpCli(opts ...HttpClientOption) *HttpCli
func (*HttpCli) HeaderIsExist ¶
func (*HttpCli) PostForHttpCliBodyer ¶
func (h *HttpCli) PostForHttpCliBodyer(url string, body httpCliBodyer) (*HttpCliResp, error)
请求体为 HttpCliBodyer, 支持多种请求协议, 默认按 protobuf 协议处理, 同时可以打印请求体
type HttpCliJsonBody ¶
type HttpCliJsonBody struct {
// contains filtered or unexported fields
}
json 协议实现 HttpCliBodyer
func NewHttpCliJsonBody ¶
func NewHttpCliJsonBody(body interface{}) *HttpCliJsonBody
type HttpCliResp ¶
func PostForHttpCliBodyer ¶
func PostForHttpCliBodyer(url string, body httpCliBodyer, headers map[string]string) (*HttpCliResp, error)
请求体为 HttpCliBodyer, 支持多种请求协议, 同时可以打印请求体
func (*HttpCliResp) Text ¶
func (h *HttpCliResp) Text() string
type HttpCliXmlBody ¶
type HttpCliXmlBody struct {
// contains filtered or unexported fields
}
xml 协议实现 HttpCliBodyer
func NewHttpCliXmlBody ¶
func NewHttpCliXmlBody(body interface{}) *HttpCliXmlBody
type HttpClientOption ¶
type HttpClientOption func(h *HttpCli)
Click to show internal directories.
Click to hide internal directories.