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.
41 lines
760 B
41 lines
760 B
package wechatopen
|
|
|
|
import (
|
|
"context"
|
|
"github.com/dtapps/go-library/utils/gorequest"
|
|
)
|
|
|
|
func (c *Client) request(ctx context.Context, url string, params map[string]interface{}, method string) (resp gorequest.Response, err error) {
|
|
|
|
// 创建请求
|
|
client := c.requestClient
|
|
|
|
// 设置请求地址
|
|
client.SetUri(url)
|
|
|
|
// 设置方式
|
|
client.SetMethod(method)
|
|
|
|
// 设置格式
|
|
client.SetContentTypeJson()
|
|
|
|
// 设置用户代理
|
|
client.SetUserAgent(gorequest.GetRandomUserAgentSystem())
|
|
|
|
// 设置参数
|
|
client.SetParams(params)
|
|
|
|
// 发起请求
|
|
request, err := client.Request(ctx)
|
|
if err != nil {
|
|
return gorequest.Response{}, err
|
|
}
|
|
|
|
// 记录日志
|
|
if c.slog.status {
|
|
go c.slog.client.Middleware(ctx, request)
|
|
}
|
|
|
|
return request, err
|
|
}
|