in internal/source/gitlab/client/client.go [146:182]
func (gc *Client) get(ctx context.Context, path string, params url.Values) (*http.Response, error) {
endpoint, err := gc.endpoint(path, params)
if err != nil {
return nil, err
}
req, err := gc.request(ctx, "GET", endpoint)
if err != nil {
return nil, err
}
resp, err := gc.httpClient.Do(req)
if err != nil {
return nil, err
}
if resp == nil {
return nil, errors.New("unknown response")
}
// StatusOK means we should return the API response
if resp.StatusCode == http.StatusOK {
return resp, nil
}
// best effort to discard and close the response body
io.Copy(io.Discard, resp.Body)
resp.Body.Close()
// StatusNoContent means that a domain does not exist, it is not an error
if resp.StatusCode == http.StatusNoContent {
return nil, nil
} else if resp.StatusCode == http.StatusUnauthorized {
return nil, ErrUnauthorizedAPI
}
return nil, fmt.Errorf("HTTP status: %d", resp.StatusCode)
}