NewCAPIClient creates a new CAPI client. Provide a token, the user's GitHub host, the resolved Copilot API URL, and an HTTP client which will be used as the base transport for CAPI requests. The provided HTTP client will be mutated for use with CAPI, so it should not be reused elsewhere.
(httpClient *http.Client, token string, host string, capiBaseURL string)
| 34 | // The provided HTTP client will be mutated for use with CAPI, so it should not |
| 35 | // be reused elsewhere. |
| 36 | func NewCAPIClient(httpClient *http.Client, token string, host string, capiBaseURL string) *CAPIClient { |
| 37 | httpClient.Transport = newCAPITransport(token, capiBaseURL, httpClient.Transport) |
| 38 | return &CAPIClient{ |
| 39 | httpClient: httpClient, |
| 40 | host: host, |
| 41 | capiBaseURL: capiBaseURL, |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | // capiTransport adds the Copilot auth headers |
| 46 | type capiTransport struct { |