| 618 | } |
| 619 | |
| 620 | func (c *Client) newRequest(ctx context.Context, rawURL string, accept string) (*http.Request, error) { |
| 621 | request, err := http.NewRequestWithContext(ctx, http.MethodGet, rawURL, http.NoBody) |
| 622 | if err != nil { |
| 623 | return nil, fmt.Errorf("github: create request %q: %w", rawURL, err) |
| 624 | } |
| 625 | request.Header.Set("Accept", accept) |
| 626 | if token := strings.TrimSpace(c.token); token != "" { |
| 627 | request.Header.Set("Authorization", "Bearer "+token) |
| 628 | } |
| 629 | return request, nil |
| 630 | } |
| 631 | |
| 632 | func (c *Client) handleRequestError(ctx context.Context, err error) (error, error) { |
| 633 | if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) || ctx.Err() != nil { |