| 35 | } |
| 36 | |
| 37 | func getAndDecode(ctx context.Context, client *http.Client, url string, dest interface{}) error { |
| 38 | req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) |
| 39 | if err != nil { |
| 40 | return err |
| 41 | } |
| 42 | |
| 43 | resp, err := client.Do(req) |
| 44 | if err != nil { |
| 45 | return err |
| 46 | } |
| 47 | defer resp.Body.Close() |
| 48 | |
| 49 | if resp.StatusCode != http.StatusOK { |
| 50 | return errors.New("non-200 status") |
| 51 | } |
| 52 | |
| 53 | return json.NewDecoder(resp.Body).Decode(dest) |
| 54 | } |
| 55 | |
| 56 | func fetchGroupData(ctx context.Context, client *http.Client, groupConfig map[string]interface{}) UptimeGroupResult { |
| 57 | url, _ := groupConfig["url"].(string) |