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/dingdanxia/request.go

46 lines
862 B

package dingdanxia
2 years ago
import (
"context"
"github.com/dtapps/go-library"
"github.com/dtapps/go-library/utils/gorequest"
)
// 请求接口
2 years ago
func (c *Client) request(ctx context.Context, url string, params map[string]interface{}, method string) (gorequest.Response, error) {
// 公共参数
2 years ago
params["apikey"] = c.GetApiKey()
// 创建请求
2 years ago
client := c.requestClient
// 设置请求地址
client.SetUri(url)
// 设置方式
client.SetMethod(method)
// 设置格式
client.SetContentTypeForm()
// 设置参数
client.SetParams(params)
2 years ago
// 传入SDk版本
client.AfferentSdkUserVersion(go_library.Version())
// 发起请求
2 years ago
request, err := client.Request(ctx)
if err != nil {
return gorequest.Response{}, err
}
2 years ago
// 记录日志
if c.log.status {
go c.log.client.Middleware(ctx, request, go_library.Version())
2 years ago
}
return request, err
}