Get chagnes to GetCandles

This commit is contained in:
zhangkun9038@dingtalk.com 2025-03-05 22:33:33 +08:00
parent f3e1506f2f
commit 75b949a50e

View File

@ -172,7 +172,7 @@ func (this *RESTAPI) GetCandles(ctx context.Context, uri string, param *map[stri
} }
// POST请求 // POST请求
func (this *RESTAPI) Post(ctx context.Context, uri string, param *map[string]interface{}) (res *RESTAPIResult, err error) { func (this *RESTAPI) Post(ctx context.Context, uri string, param *map[string]interface{}) (res ResponseData, err error) {
this.Method = POST this.Method = POST
this.Uri = uri this.Uri = uri
@ -212,7 +212,7 @@ func (this *RESTAPI) Run(ctx context.Context) (ResponseData, error) {
uri, body, err := this.GenReqInfo() uri, body, err := this.GenReqInfo()
if err != nil { if err != nil {
return return nil, err
} }
url := this.EndPoint + uri url := this.EndPoint + uri
@ -221,7 +221,7 @@ func (this *RESTAPI) Run(ctx context.Context) (ResponseData, error) {
req, err := http.NewRequest(this.Method, url, bodyBuf) req, err := http.NewRequest(this.Method, url, bodyBuf)
if err != nil { if err != nil {
return return nil, err
} }
res = &RESTAPIResult{ res = &RESTAPIResult{
@ -235,7 +235,7 @@ func (this *RESTAPI) Run(ctx context.Context) (ResponseData, error) {
//log.Println("preHash:", preHash) //log.Println("preHash:", preHash)
sign, err := utils.HmacSha256Base64Signer(preHash, this.ApiKeyInfo.SecKey) sign, err := utils.HmacSha256Base64Signer(preHash, this.ApiKeyInfo.SecKey)
if err != nil { if err != nil {
return return nil, err
} }
//log.Println("sign:", sign) //log.Println("sign:", sign)
headStr := this.SetHeaders(req, timestamp, sign) headStr := this.SetHeaders(req, timestamp, sign)
@ -245,7 +245,7 @@ func (this *RESTAPI) Run(ctx context.Context) (ResponseData, error) {
resp, err := client.Do(req) resp, err := client.Do(req)
if err != nil { if err != nil {
fmt.Println("请求失败!", err) fmt.Println("请求失败!", err)
return return nil, err
} }
defer resp.Body.Close() defer resp.Body.Close()
@ -254,7 +254,7 @@ func (this *RESTAPI) Run(ctx context.Context) (ResponseData, error) {
resBuff, err := ioutil.ReadAll(resp.Body) resBuff, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
fmt.Println("获取请求结果失败!", err) fmt.Println("获取请求结果失败!", err)
return return nil, err
} }
res.Body = string(resBuff) res.Body = string(resBuff)
@ -265,12 +265,12 @@ func (this *RESTAPI) Run(ctx context.Context) (ResponseData, error) {
err = json.Unmarshal(resBuff, &v5rsp) err = json.Unmarshal(resBuff, &v5rsp)
if err != nil { if err != nil {
fmt.Println("解析v5返回失败", err) fmt.Println("解析v5返回失败", err)
return return nil, err
} }
res.V5Response = v5rsp res.V5Response = v5rsp
return return nil, err
} }
/* /*