third-platform-sdk/platform/eleme-union/client.go
2024-04-30 17:57:27 +08:00

55 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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
}