NewHTTPFetcher creates a new HTTPFetcher with the given endpoint and HTTP client.
( endpoint string, httpClient *http.Client)
| 72 | |
| 73 | // NewHTTPFetcher creates a new HTTPFetcher with the given endpoint and HTTP client. |
| 74 | func NewHTTPFetcher( |
| 75 | endpoint string, httpClient *http.Client) (*HTTPFetcher, error) { |
| 76 | u, err := url.Parse(endpoint) |
| 77 | if err != nil { |
| 78 | return nil, errors.Join(ErrUnableToParseURL, err) |
| 79 | } |
| 80 | |
| 81 | return &HTTPFetcher{ |
| 82 | httpClient: httpClient, |
| 83 | endpoint: u, |
| 84 | }, nil |
| 85 | } |
| 86 | |
| 87 | // Fetch performs an HTTP GET request to the configured endpoint. |
| 88 | // It returns the response body as an io.ReadCloser on success. |