|
3 | 3 | package rubygemsclient |
4 | 4 |
|
5 | 5 | import ( |
| 6 | + "context" |
6 | 7 | "encoding/json" |
7 | 8 | "fmt" |
8 | 9 | "net/http" |
@@ -63,7 +64,12 @@ func (c *Client) GetGemInfo(name, version string) (*GemInfo, error) { |
63 | 64 | // In production, we'd use the compact index or version-specific APIs |
64 | 65 | url := fmt.Sprintf("%s/gems/%s.json", c.baseURL, name) |
65 | 66 |
|
66 | | - resp, err := c.httpClient.Get(url) |
| 67 | + req, err := http.NewRequestWithContext(context.Background(), "GET", url, http.NoBody) |
| 68 | + if err != nil { |
| 69 | + return nil, fmt.Errorf("failed to create request: %w", err) |
| 70 | + } |
| 71 | + |
| 72 | + resp, err := c.httpClient.Do(req) |
67 | 73 | if err != nil { |
68 | 74 | return nil, fmt.Errorf("failed to fetch gem info: %w", err) |
69 | 75 | } |
@@ -94,7 +100,12 @@ type VersionInfo struct { |
94 | 100 | func (c *Client) GetGemVersions(name string) ([]string, error) { |
95 | 101 | url := fmt.Sprintf("%s/versions/%s.json", c.baseURL, name) |
96 | 102 |
|
97 | | - resp, err := c.httpClient.Get(url) |
| 103 | + req, err := http.NewRequestWithContext(context.Background(), "GET", url, http.NoBody) |
| 104 | + if err != nil { |
| 105 | + return nil, fmt.Errorf("failed to create request: %w", err) |
| 106 | + } |
| 107 | + |
| 108 | + resp, err := c.httpClient.Do(req) |
98 | 109 | if err != nil { |
99 | 110 | return nil, fmt.Errorf("failed to fetch gem versions: %w", err) |
100 | 111 | } |
@@ -165,4 +176,3 @@ func (c *Client) GetMultipleGemInfo(requests []GemInfoRequest) []GemInfoResult { |
165 | 176 | wg.Wait() |
166 | 177 | return results |
167 | 178 | } |
168 | | - |
|
0 commit comments