2021-06-01 10:51:35 +02:00
|
|
|
package web
|
2019-08-07 00:15:50 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
"net/http"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2021-06-01 17:41:05 +02:00
|
|
|
// JSONRequest easy get request for json
|
2019-08-07 00:15:50 +02:00
|
|
|
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
|
|
|
|
}
|