(ctx context.Context, url string)
| 129 | } |
| 130 | |
| 131 | func fetchFromHTTP(ctx context.Context, url string) ([]byte, error) { |
| 132 | req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) |
| 133 | if err != nil { |
| 134 | return nil, fmt.Errorf("failed to create HTTP request: %w", err) |
| 135 | } |
| 136 | |
| 137 | resp, err := http.DefaultClient.Do(req) |
| 138 | if err != nil { |
| 139 | return nil, fmt.Errorf("failed to fetch from HTTP: %w", err) |
| 140 | } |
| 141 | defer resp.Body.Close() |
| 142 | |
| 143 | if resp.StatusCode != http.StatusOK { |
| 144 | return nil, fmt.Errorf("HTTP request failed with status: %d", resp.StatusCode) |
| 145 | } |
| 146 | |
| 147 | return io.ReadAll(resp.Body) |
| 148 | } |
| 149 | |
| 150 | func fetchFromRegistryAPI(ctx context.Context, baseURL string) ([]*apiv0.ServerJSON, error) { |
| 151 | var allRecords []*apiv0.ServerJSON |
no test coverage detected
searching dependent graphs…