Documentation ¶
Index ¶
- func FastJsonMarshal(v interface{}) ([]byte, error)
- func FastJsonUnMarshal(data []byte, v interface{}) error
- func HttpCaller(method, url string, options ...Option) *http.Response
- func MontageUrl(host, apiUrl string, pathParam ...interface{}) string
- func ResponseToMap(responseIns *http.Response) map[string]interface{}
- func ResponseToStruct(responseIns *http.Response, v interface{}) error
- type HttpRequests
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FastJsonUnMarshal ¶
FastJsonUnMarshal json反序列化
func HttpCaller ¶
HttpCaller 发起请求 method: HTTP method (GET, POST, PUT,DELETE) url: 请求的url
func MontageUrl ¶
MontageUrl 拼接测试的接口URL,但是不拼接查询参数,主要是为了拼接最终的url 路径参数格式为列表 ["334","456"] 当路径参数没有时,拼接的路径为 https://host/apiUrl 当路径参数参数有时,按路径顺序拼接的路径为 https://host/apiUrl/pathParam/334/456
func ResponseToMap ¶
ResponseToMap 将响应结果转为map
func ResponseToStruct ¶
ResponseToStruct 将字节切片类型的接口响应转接结构,通过结构体取值 response:请求的响应对象 v:结构体指针
Types ¶
type HttpRequests ¶
type Option ¶
type Option func(*HttpRequests)
func WithParams ¶
WithParams 设置查询参数,且对url的参数进行encode
func WithPostJsonBody ¶
WithPostJsonBody 当headers的Content-Type是application/json HTTP会将请求参数以"键-值”"的方式组织的JSON格式数据,放到请求body里面
func WithPostStringBody ¶
WithPostStringBody 当headers的Content-Type是application/x-www-form-urlencoded HTTP会将请求参数用key1=val1&key2=val2的方式进行组织,并放到请求body里面
Click to show internal directories.
Click to hide internal directories.