Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
ErrUnableToParseURL = errors.New("unable to parse URL")
)
Functions ¶
This section is empty.
Types ¶
type FetchOption ¶
type FetchOption func(*FetchOptions)
FetchOption is a function that modifies the FetchOptions.
func WithExpectedStatusCodes ¶
func WithExpectedStatusCodes(codes []int) FetchOption
WithExpectedStatusCodes sets the expected status codes for the HTTP response.
func WithHeaders ¶
func WithHeaders(headers map[string]string) FetchOption
WithHeaders sets the headers for the HTTP request.
type FetchOptions ¶
type FetchOptions struct { Request RequestOptions Response ResponseOptions }
FetchOptions holds options for an HTTP fetch operation.
type HTTPFetcher ¶
type HTTPFetcher struct {
// contains filtered or unexported fields
}
func NewHTTPFetcher ¶
func NewHTTPFetcher( endpoint string, httpClient *http.Client) (*HTTPFetcher, error)
NewHTTPFetcher creates a new HTTPFetcher with the given endpoint and HTTP client.
func (HTTPFetcher) Fetch ¶
func (f HTTPFetcher) Fetch(ctx context.Context, opts ...FetchOption) (io.ReadCloser, error)
Fetch performs an HTTP GET request to the configured endpoint. It returns the response body as an io.ReadCloser on success. The caller is responsible for closing the reader. It accepts a variable number of FetchOption functions to customize the request and response handling.
type RequestOptions ¶
RequestOptions holds options for the HTTP request.
type ResponseOptions ¶
type ResponseOptions struct { // A list of status codes that are considered successful. If empty, only http.StatusOK is considered successful. ExpectedStatusCodes []int }
ResponseOptions holds options for handling the HTTP response.