mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
fix: Refactor agent to consume API client (#4715)
* fix: Refactor agent to consume API client This simplifies a lot of code by creating an interface for the codersdk client into the agent. It also moves agent authentication code so instance identity will work between restarts. Fixes #3485 and #4082. * Fix client reconnections
This commit is contained in:
@@ -105,6 +105,9 @@ func (c *Client) Request(ctx context.Context, method, path string, body interfac
|
||||
// readBodyAsError reads the response as an .Message, and
|
||||
// wraps it in a codersdk.Error type for easy marshaling.
|
||||
func readBodyAsError(res *http.Response) error {
|
||||
if res == nil {
|
||||
return xerrors.Errorf("no body returned")
|
||||
}
|
||||
defer res.Body.Close()
|
||||
contentType := res.Header.Get("Content-Type")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user