Get chagnes to GetCandles
This commit is contained in:
parent
f3e1506f2f
commit
75b949a50e
16
rest/rest.go
16
rest/rest.go
@ -172,7 +172,7 @@ func (this *RESTAPI) GetCandles(ctx context.Context, uri string, param *map[stri
|
||||
}
|
||||
|
||||
// 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.Uri = uri
|
||||
|
||||
@ -212,7 +212,7 @@ func (this *RESTAPI) Run(ctx context.Context) (ResponseData, error) {
|
||||
|
||||
uri, body, err := this.GenReqInfo()
|
||||
if err != nil {
|
||||
return
|
||||
return nil, err
|
||||
}
|
||||
|
||||
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)
|
||||
if err != nil {
|
||||
return
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res = &RESTAPIResult{
|
||||
@ -235,7 +235,7 @@ func (this *RESTAPI) Run(ctx context.Context) (ResponseData, error) {
|
||||
//log.Println("preHash:", preHash)
|
||||
sign, err := utils.HmacSha256Base64Signer(preHash, this.ApiKeyInfo.SecKey)
|
||||
if err != nil {
|
||||
return
|
||||
return nil, err
|
||||
}
|
||||
//log.Println("sign:", 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)
|
||||
if err != nil {
|
||||
fmt.Println("请求失败!", err)
|
||||
return
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
@ -254,7 +254,7 @@ func (this *RESTAPI) Run(ctx context.Context) (ResponseData, error) {
|
||||
resBuff, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
fmt.Println("获取请求结果失败!", err)
|
||||
return
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.Body = string(resBuff)
|
||||
@ -265,12 +265,12 @@ func (this *RESTAPI) Run(ctx context.Context) (ResponseData, error) {
|
||||
err = json.Unmarshal(resBuff, &v5rsp)
|
||||
if err != nil {
|
||||
fmt.Println("解析v5返回失败!", err)
|
||||
return
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res.V5Response = v5rsp
|
||||
|
||||
return
|
||||
return nil, err
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user