parent
508ee7c0f8
commit
405aa99fd0
@ -0,0 +1,9 @@
|
||||
package wechatopen
|
||||
|
||||
const (
|
||||
apiUrl = "https://api.weixin.qq.com"
|
||||
)
|
||||
|
||||
const (
|
||||
logTable = "wechatopen"
|
||||
)
|
@ -1,27 +0,0 @@
|
||||
package wechatopen
|
||||
|
||||
// Params 请求参数
|
||||
type Params map[string]interface{}
|
||||
|
||||
func NewParams() Params {
|
||||
p := make(Params)
|
||||
return p
|
||||
}
|
||||
|
||||
func (c *Client) NewParamsWith(params ...Params) Params {
|
||||
p := make(Params)
|
||||
for _, v := range params {
|
||||
p.SetParams(v)
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func (p Params) Set(key string, value interface{}) {
|
||||
p[key] = value
|
||||
}
|
||||
|
||||
func (p Params) SetParams(params Params) {
|
||||
for key, value := range params {
|
||||
p[key] = value
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package wechatopen
|
||||
|
||||
import "go.dtapp.net/library/utils/gorequest"
|
||||
|
||||
func (c *Client) request(url string, params map[string]interface{}, method string) (resp gorequest.Response, err error) {
|
||||
|
||||
// 创建请求
|
||||
client := c.client
|
||||
|
||||
// 设置请求地址
|
||||
client.SetUri(url)
|
||||
|
||||
// 设置方式
|
||||
client.SetMethod(method)
|
||||
|
||||
// 设置格式
|
||||
client.SetContentTypeJson()
|
||||
|
||||
// 设置参数
|
||||
client.SetParams(params)
|
||||
|
||||
// 发起请求
|
||||
request, err := client.Request()
|
||||
if err != nil {
|
||||
return gorequest.Response{}, err
|
||||
}
|
||||
|
||||
// 日志
|
||||
if c.logStatus == true {
|
||||
go c.postgresqlLog(request)
|
||||
}
|
||||
|
||||
return request, err
|
||||
}
|
Loading…
Reference in new issue