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:
Ryan O'Hara-Reid
2019-01-31 16:11:42 +11:00
committed by Adrian Gallagher
parent f7810e7eca
commit 82a622294c
10 changed files with 1819 additions and 10 deletions

View File

@@ -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
}