This commit is contained in:
2024-05-31 13:35:39 +03:00
parent e7c968797b
commit 3393934456
65 changed files with 905 additions and 393 deletions

View File

@@ -73,12 +73,20 @@ func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url st
return nil, err
}
values, err := query.Values(params)
if err != nil {
return nil, err
}
var body *bytes.Buffer
var ctype string
body := bytes.NewBufferString(values.Encode() + fmt.Sprintf("&authkey=%s", ldc.cfg.Token))
byteSlice, ok := params.([]byte)
if ok {
body = bytes.NewBuffer(byteSlice)
ctype = "application/octet-stream"
} else {
values, err := query.Values(params)
if err != nil {
return nil, err
}
body = bytes.NewBufferString(values.Encode() + fmt.Sprintf("&authkey=%s", ldc.cfg.Token))
}
req, err := http.NewRequestWithContext(ctx, method, ldc.decortURL+constants.RESTMACHINE+url, body)
if err != nil {
@@ -86,7 +94,7 @@ func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url st
}
// perform request
respBytes, err := ldc.do(req, "")
respBytes, err := ldc.do(req, ctype)
if err != nil {
return nil, err
}