don't use ReadAll when decoding JSON

An empty stream isn't valid JSON, so we shouldn't silently ignore it.
This commit is contained in:
Daniel Martí
2019-05-27 11:02:50 +01:00
parent 098d963881
commit 9bcdcc128f
11 changed files with 29 additions and 53 deletions
+3 -1
View File
@@ -1,6 +1,8 @@
package jira
import (
"encoding/json"
"gopkg.in/Netflix-Skunkworks/go-jira.v1/jiradata"
)
@@ -18,7 +20,7 @@ func GetFields(ua HttpClient, endpoint string) ([]jiradata.Field, error) {
defer resp.Body.Close()
if resp.StatusCode == 200 {
results := []jiradata.Field{}
return results, readJSON(resp.Body, &results)
return results, json.NewDecoder(resp.Body).Decode(&results)
}
return nil, responseError(resp)
}