You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package wechatunion
|
|
|
|
|
|
|
|
import "github.com/dtapps/go-library/utils/gorequest"
|
|
|
|
|
|
|
|
// 请求
|
|
|
|
func (c *Client) request(url string, params map[string]interface{}, method string) (gorequest.Response, error) {
|
|
|
|
|
|
|
|
// 创建请求
|
|
|
|
client := c.client
|
|
|
|
|
|
|
|
// 设置请求地址
|
|
|
|
client.SetUri(url)
|
|
|
|
|
|
|
|
// 设置请求方式
|
|
|
|
client.SetMethod(method)
|
|
|
|
|
|
|
|
// 设置FORM格式
|
|
|
|
client.SetContentTypeForm()
|
|
|
|
|
|
|
|
// 设置参数
|
|
|
|
client.SetParams(params)
|
|
|
|
|
|
|
|
// 发起请求
|
|
|
|
request, err := client.Request()
|
|
|
|
if err != nil {
|
|
|
|
return gorequest.Response{}, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// 日志
|
|
|
|
if c.config.PgsqlDb != nil {
|
|
|
|
go c.log.GormMiddleware(request)
|
|
|
|
}
|
|
|
|
if c.config.MongoDb != nil {
|
|
|
|
go c.log.MongoMiddleware(request)
|
|
|
|
}
|
|
|
|
|
|
|
|
return request, err
|
|
|
|
}
|