refactor: move catalogue logic into own package

This commit is contained in:
2021-07-28 22:10:13 +02:00
parent bf0212c520
commit 1187d6bfd5
4 changed files with 173 additions and 158 deletions

17
catalogue/common.go Normal file
View 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)
}