refactoring

This commit is contained in:
2026-01-19 16:55:33 +01:00
parent 197a01440c
commit 64750ef1c2
5 changed files with 83 additions and 63 deletions

21
lib/fetcher.go Normal file
View File

@@ -0,0 +1,21 @@
package lib
import (
"encoding/json"
"net/http"
)
// Fetcher is the interface for a fetcher.
type Fetcher interface {
Fetch() []string
}
func getJSON(req *http.Request, target interface{}) error {
res, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer res.Body.Close()
return json.NewDecoder(res.Body).Decode(target)
}