Documentation ¶
Index ¶
- Constants
- func Do(ctx context.Context, rawRequest *http.Request, config *HttpConfig) (rawResponse *http.Response, err error)
- func InitHttpClient(config *HttpConfig) (err error)
- type HttpConfig
- type Request
- func NewDoRequest(rawReq *http.Request, config *HttpConfig) (req *Request, err error)
- func NewGetRequest(reqUrl string, query *url.Values, config *HttpConfig) (req *Request, err error)
- func NewPostFileRequest(reqUrl string, query *url.Values, form *url.Values, files map[string]io.Reader, ...) (req *Request, err error)
- func NewPostJsonRequest(reqUrl string, query *url.Values, json []byte, config *HttpConfig) (req *Request, err error)
- func NewPostRequest(reqUrl string, query *url.Values, form *url.Values, config *HttpConfig) (req *Request, err error)
- type Response
- func Get(ctx context.Context, reqUrl string, query *url.Values, config *HttpConfig) (response *Response, err error)
- func MultiRequest(ctx context.Context, reqList []*Request) (respList []*Response, err error)
- func Post(ctx context.Context, reqUrl string, query *url.Values, form *url.Values, ...) (response *Response, err error)
- func PostFile(ctx context.Context, reqUrl string, query *url.Values, form *url.Values, ...) (response *Response, err error)
- func PostJson(ctx context.Context, reqUrl string, query *url.Values, json []byte, ...) (response *Response, err error)
- type TraceData
Constants ¶
View Source
const CAT_POST_LEN_LIMIT = 200
View Source
const CTX_TRACEDATA_KEY = "tracedata"
View Source
const DEFAULT_TIMEOUT = 3000
默认超时时间
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HttpConfig ¶
type HttpConfig struct { Timeout int `toml:"timeout"` // 连接超时时间 Header map[string]string Cookie []*http.Cookie }
请求配置
type Request ¶
type Request struct { RawReq *http.Request // 原始请求 Config *HttpConfig // 请求级配置 Form *url.Values // form传参 // contains filtered or unexported fields }
请求封装
func NewDoRequest ¶
func NewDoRequest(rawReq *http.Request, config *HttpConfig) (req *Request, err error)
创建Do请求
func NewGetRequest ¶
创建GET请求
func NewPostFileRequest ¶
func NewPostFileRequest(reqUrl string, query *url.Values, form *url.Values, files map[string]io.Reader, config *HttpConfig) (req *Request, err error)
创建POST FILE请求
func NewPostJsonRequest ¶
func NewPostJsonRequest(reqUrl string, query *url.Values, json []byte, config *HttpConfig) (req *Request, err error)
创建POST JSON请求
func NewPostRequest ¶
func NewPostRequest(reqUrl string, query *url.Values, form *url.Values, config *HttpConfig) (req *Request, err error)
创建POST表单请求
type Response ¶
应答封装
func Get ¶
func Get(ctx context.Context, reqUrl string, query *url.Values, config *HttpConfig) (response *Response, err error)
GET请求
func MultiRequest ¶
并发调用
func Post ¶
func Post(ctx context.Context, reqUrl string, query *url.Values, form *url.Values, config *HttpConfig) (response *Response, err error)
POST表单
Click to show internal directories.
Click to hide internal directories.