| 65 | } |
| 66 | |
| 67 | func (c *Client) authHeaders(req *http.Request) error { |
| 68 | if c.Config == nil { |
| 69 | return fmt.Errorf("not authenticated — run 'cloudcent init' first") |
| 70 | } |
| 71 | if c.Config.APIKey == nil { |
| 72 | return fmt.Errorf("API key not found in config") |
| 73 | } |
| 74 | req.Header.Set("X-Cli-Id", c.Config.CliID) |
| 75 | req.Header.Set("Authorization", "Bearer "+*c.Config.APIKey) |
| 76 | return nil |
| 77 | } |
| 78 | |
| 79 | func (c *Client) doRequest(method, endpoint string, body io.Reader, contentType string, requireAuth bool) (int, []byte, error) { |
| 80 | req, err := http.NewRequest(method, endpoint, body) |