1 Star 0 Fork 0

zqs / go-okx

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
client.go 1.62 KB
一键复制 编辑 原始数据 按行查看 历史
zhouqiusheng 提交于 2022-10-31 13:32 . 定义常量
package okex
import (
"gitee.com/zqs118/go-okx/common"
"strings"
"time"
)
const (
baseApiUrl common.BaseURL = "https://www.okex.com"
baseApiAwsUrl common.BaseURL = "https://aws.okex.com"
baseApiTestUrl common.BaseURL = "https://www.okex.com"
OkAccessKey = "OK-ACCESS-KEY"
OkAccessSign = "OK-ACCESS-SIGN"
OkAccessTimeStamp = "OK-ACCESS-TIMESTAMP"
OkAccessPassphrase = "OK-ACCESS-PASSPHRASE"
XSimulatedTrading = "x-simulated-trading"
ContentType = "Content-Type"
Accept = "Accept"
Cookie = "Cookie"
Locale = "locale="
ApplicationJson = "application/json"
ApplicationJsonUtf8 = "application/json; charset=UTF-8"
English = "en_US"
SimplifiedChinese = "zh_CN"
TraditionalChinese = "zh_HK"
)
var TimeOut = 10 * time.Second
type Client struct {
Config *Config
Method common.RequestMethod
Url string
Param map[string]interface{}
BaseURL common.BaseURL
timeout time.Duration
}
func getBaseUrl() common.BaseURL {
if UseTestnet {
return baseApiTestUrl
} else {
if UseAWSnet {
return baseApiAwsUrl
} else {
return baseApiUrl
}
}
}
// NewClient 初始化rest api客户端
func NewClient(config *Config) *Client {
return &Client{
Config: config,
BaseURL: getBaseUrl(),
timeout: TimeOut,
}
}
func (r *Client) SetMethod(method common.RequestMethod) *Client {
r.Method = method
return r
}
func (r *Client) SetUrl(url string) *Client {
if !strings.HasPrefix(url, "/") {
url = "/" + url
}
r.Url = url
return r
}
func (r *Client) SetParam(param map[string]interface{}) *Client {
r.Param = param
return r
}
1
https://gitee.com/zqs118/go-okx.git
git@gitee.com:zqs118/go-okx.git
zqs118
go-okx
go-okx
v0.1.5

搜索帮助

53164aa7 5694891 3bd8fe86 5694891