forked from toolshed/abra
refactor: move catalogue logic into own package
This commit is contained in:
17
catalogue/common.go
Normal file
17
catalogue/common.go
Normal file
@ -0,0 +1,17 @@
|
||||
package catalogue
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func readJson(url string, target interface{}) error {
|
||||
httpClient := &http.Client{Timeout: 5 * time.Second}
|
||||
res, err := httpClient.Get(url)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
return json.NewDecoder(res.Body).Decode(target)
|
||||
}
|
Reference in New Issue
Block a user