- 新增 AddHeaders 方法支持批量添加请求头参数 - 新增 RefererHeader 结构体用于管理 Referer 和 TraceId - 添加随机字符串生成工具包 random - 集成 MD5 加密和追踪 ID 生成功能 - 修改 IP 服务域名从 ip.gaore.com 到 ip.gaore.com.hk - 在客户端请求中自动添加 Referer 和 Traceparent 头信息
45 lines
914 B
Go
45 lines
914 B
Go
package ip
|
|
|
|
import (
|
|
"fmt"
|
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk"
|
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
|
)
|
|
|
|
const (
|
|
VERSION = "2025-06-24"
|
|
)
|
|
|
|
var HOST = requests.Host{
|
|
Default: "ip.gaore.com.hk",
|
|
Func: func(s string, area string) string {
|
|
if area != "" {
|
|
fmt.Println("ip.gaore.com." + area)
|
|
return "ip.gaore.com." + area
|
|
}
|
|
return "ip.gaore.com.hk"
|
|
},
|
|
}
|
|
|
|
type Client struct {
|
|
sdk.Client
|
|
}
|
|
|
|
func NewClient(area string, env ...string) (client *Client, err error) {
|
|
client = new(Client)
|
|
err = client.InitWithArea(area, env...)
|
|
return
|
|
}
|
|
|
|
func (client *Client) CreateGetIpRequest(req *IpRequest) (resp *IpResponse, err error) {
|
|
resp = CreateIpResponse()
|
|
err = client.DoAction(req, resp)
|
|
return
|
|
}
|
|
|
|
func (client *Client) CreateGetIpsRequest(req *IpsRequest) (resp *IpsResponse, err error) {
|
|
resp = CreateIpsResponse()
|
|
err = client.DoAction(req, resp)
|
|
return
|
|
}
|