refactor: use web module timeout everywhere

This commit is contained in:
2021-09-04 23:18:34 +02:00
parent e68c7fc71c
commit a3e02540f6
3 changed files with 8 additions and 5 deletions

View File

@ -6,9 +6,13 @@ import (
"time"
)
// Timeout is the time it takes before a web request bails out waiting for a
// request.
const Timeout = 10 * time.Second
// ReadJSON reads JSON and parses it into your chosen interface pointer
func ReadJSON(url string, target interface{}) error {
httpClient := &http.Client{Timeout: 5 * time.Second}
httpClient := &http.Client{Timeout: Timeout}
res, err := httpClient.Get(url)
if err != nil {
return err