55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
|
|
package eleme_union
|
|||
|
|
|
|||
|
|
import (
|
|||
|
|
"net/http"
|
|||
|
|
|
|||
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|||
|
|
|
|||
|
|
"chengdu-lenntc/third-platform-sdk/client"
|
|||
|
|
"chengdu-lenntc/third-platform-sdk/util"
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
// AuthConfig api鉴权参数
|
|||
|
|
type AuthConfig struct {
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// todo:: 连接第三方平台的client
|
|||
|
|
type Client struct {
|
|||
|
|
client.ThirdClient
|
|||
|
|
log logx.Logger
|
|||
|
|
authConfig AuthConfig
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
func NewClient(log logx.Logger, conf AuthConfig) *Client {
|
|||
|
|
// todo:: 请求第三方平台的配置参数
|
|||
|
|
return &Client{
|
|||
|
|
ThirdClient: client.NewThirdClient(log),
|
|||
|
|
log: log,
|
|||
|
|
authConfig: conf,
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// todo:: DoHttp 发起http请求
|
|||
|
|
func (c *Client) DoHttp(method string, url string, req *client.HttpRequest, resp *client.HttpResponse) error {
|
|||
|
|
// todo:: api请求频率限制?
|
|||
|
|
c.apiRateLimit()
|
|||
|
|
// 发起请求
|
|||
|
|
err := c.ThirdClient.DoHttp(method, url, req, resp)
|
|||
|
|
return err
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// todo:: 请求api的频率限制
|
|||
|
|
func (c *Client) apiRateLimit() {
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// todo:: 检查api请求频率限制
|
|||
|
|
func (c *Client) checkRateLimit(header *http.Header) error {
|
|||
|
|
return nil
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// todo:: 检查http响应错误
|
|||
|
|
func (c *Client) checkResponseError(r *util.Response) error {
|
|||
|
|
return nil
|
|||
|
|
}
|