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.
go-library/service/pintoto/request.go

44 lines
773 B

2 years ago
package pintoto
import (
2 years ago
"context"
2 years ago
"github.com/dtapps/go-library/utils/gorequest"
2 years ago
"time"
)
// 请求
2 years ago
func (c *Client) request(ctx context.Context, url string, params map[string]interface{}) (gorequest.Response, error) {
2 years ago
// 公共参数
params["time"] = time.Now().Unix()
params["appKey"] = c.GetAppKey()
// 签名
params["sign"] = c.getSign(c.GetAppSecret(), params)
// 创建请求
client := c.requestClient
2 years ago
// 设置请求地址
client.SetUri(url)
// 设置格式
client.SetContentTypeForm()
// 设置参数
client.SetParams(params)
// 发起请求
2 years ago
request, err := client.Post(ctx)
2 years ago
if err != nil {
return gorequest.Response{}, err
}
// 记录日志
1 year ago
if c.zap.status {
go c.zap.client.Middleware(ctx, request)
2 years ago
}
2 years ago
return request, err
}