Files
updater/lib/fetcher.go
2026-01-20 01:12:17 +01:00

28 lines
445 B
Go

package lib
import (
"encoding/json"
"net/http"
)
// Entry represents a single fetched item.
type Entry struct {
Title string
URL string
}
// Fetcher is the interface for a fetcher.
type Fetcher interface {
Fetch() []Entry
}
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)
}