mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-30 23:16:52 +00:00
Coinmarketcap implementation (#243)
* Updates requester package to allow unpacking of zipped files and defaults to warn if no JSON is present * Initial addition of coinmarketcap functionality * fix requested changes * Fix issue with displaying false positive in request.go && reorder plan list * Rename CurrencyProvider -> CryptocurrencyProvider Skip seeding currency data if not enabled Rm line in main.go * Update test procedures and relevant json files * Fix const issue within config.go
This commit is contained in:
committed by
Adrian Gallagher
parent
f7810e7eca
commit
82a622294c
@@ -1,6 +1,7 @@
|
||||
package request
|
||||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -290,7 +291,31 @@ func (r *Requester) DoRequest(req *http.Request, method, path string, headers ma
|
||||
return errors.New("resp is nil")
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadAll(resp.Body)
|
||||
var reader io.ReadCloser
|
||||
switch resp.Header.Get("Content-Encoding") {
|
||||
case "gzip":
|
||||
reader, err = gzip.NewReader(resp.Body)
|
||||
defer reader.Close()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
case "json":
|
||||
reader = resp.Body
|
||||
|
||||
default:
|
||||
switch {
|
||||
case common.StringContains(resp.Header.Get("Content-Type"), "application/json"):
|
||||
reader = resp.Body
|
||||
|
||||
default:
|
||||
log.Warnf("encoding is not JSON for request response but receieved %v",
|
||||
resp.Header.Get("Content-Type"))
|
||||
reader = resp.Body
|
||||
}
|
||||
}
|
||||
|
||||
contents, err := ioutil.ReadAll(reader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user