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"
)
@@ -19,7 +21,7 @@ func GetProjectComponents(ua HttpClient, endpoint string, project string) (*jira
if resp.StatusCode == 200 {
results := jiradata.Components{}
return &results, readJSON(resp.Body, &results)
return &results, json.NewDecoder(resp.Body).Decode(&results)
}
return nil, responseError(resp)
}