mirror of
https://github.com/Threnklyn/jira.git
synced 2026-05-18 20:23:28 +02:00
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:
@@ -1,29 +1,11 @@
|
||||
package jira
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/url"
|
||||
"path"
|
||||
)
|
||||
|
||||
func readJSON(input io.Reader, data interface{}) error {
|
||||
content, err := ioutil.ReadAll(input)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(content) == 0 {
|
||||
return nil
|
||||
}
|
||||
err = json.Unmarshal(content, data)
|
||||
if err != nil {
|
||||
return fmt.Errorf("JSON Parse Error: %s from %q", err, content)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func URLJoin(endpoint string, paths ...string) string {
|
||||
u, err := url.Parse(endpoint)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user