10000 add ctx propagation to raw api call · github/github-mcp-server@2711384 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2711384

Browse files
kerobbiSamMorrowDrums
authored andcommitted
add ctx propagation to raw api call
1 parent b2901e1 commit 2711384

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)
0