Skip to content

Commit 68b2236

Browse files
committed
add ctx propagation to raw api call
1 parent 3fe88ee commit 68b2236

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pkg/raw/raw.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ func NewClient(client *gogithub.Client, rawURL *url.URL) *Client {
2525
return &Client{client: client, url: rawURL}
2626
}
2727

28-
func (c *Client) newRequest(method string, urlStr string, body interface{}, opts ...gogithub.RequestOption) (*http.Request, error) {
28+
func (c *Client) newRequest(ctx context.Context, method string, urlStr string, body interface{}, opts ...gogithub.RequestOption) (*http.Request, error) {
2929
req, err := c.client.NewRequest(method, urlStr, body, opts...)
30-
return req, err
30+
if err != nil {
31+
return nil, err
32+
}
33+
req = req.WithContext(ctx)
34+
return req, nil
3135
}
3236

3337
func (c *Client) refURL(owner, repo, ref, path string) string {
@@ -60,7 +64,7 @@ type RawContentOpts struct {
6064
// GetRawContent fetches the raw content of a file from a GitHub repository.
6165
func (c *Client) GetRawContent(ctx context.Context, owner, repo, path string, opts *RawContentOpts) (*http.Response, error) {
6266
url := c.URLFromOpts(opts, owner, repo, path)
63-
req, err := c.newRequest("GET", url, nil)
67+
req, err := c.newRequest(ctx, "GET", url, nil)
6468
if err != nil {
6569
return nil, err
6670
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy