diff --git a/http/request.go b/http/request.go new file mode 100644 index 0000000..5ac5171 --- /dev/null +++ b/http/request.go @@ -0,0 +1,24 @@ +package http + +import ( + "encoding/json" + "net/http" + "time" +) + +func JSONRequest(url string, value interface{}) error { + var netClient = &http.Client{ + Timeout: time.Second * 20, + } + + resp, err := netClient.Get(url) + if err != nil { + return err + } + + err = json.NewDecoder(resp.Body).Decode(&value) + if err != nil { + return err + } + return nil +}