forked from toolshed/abra
refactor: use web module timeout everywhere
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user