func lxdParseResponse(resp *http.Response) (*api.Response, string, error) {
	// Get the ETag
	etag := resp.Header.Get("ETag")

	// Decode the response
	decoder := json.NewDecoder(resp.Body)
	response := api.Response{}

	err := decoder.Decode(&response)
	if err != nil {
		// Check the return value for a cleaner error
		if resp.StatusCode != http.StatusOK {
			return nil, "", fmt.Errorf("Failed to fetch %s: %s", resp.Request.URL.String(), resp.Status)
		}

		return nil, "", err
	}

	// Handle errors
	if response.Type == api.ErrorResponse {
		return nil, "", fmt.Errorf(response.Error)
	}

	return &response, etag, nil
}
func lxdParseResponse(resp *http.Response) (*api.Response, string, error) {
	
	etag := resp.Header.Get("ETag")

	
	decoder := json.NewDecoder(resp.Body)
	response := api.Response{}

	err := decoder.Decode(&response)
	if err != nil {
		
		if resp.StatusCode != http.StatusOK {
			return nil, "", fmt.Errorf("Failed to fetch %s: %s", resp.Request.URL.String(), resp.Status)
		}

		return nil, "", err
	}

	
	if response.Type == api.ErrorResponse {
		return nil, "", fmt.Errorf(response.Error)
	}

	return &response, etag, nil
}
func lxdParseResponse ( resp * http . Response ) ( * api . Response , string , error ) { // Get the ETag etag := resp . Header . Get ( " " ) // Decode the response decoder := json . NewDecoder ( resp . Body ) response := api . Response { } err := decoder . Decode ( & response ) if err != nil { // Check the return value for a cleaner error if resp . StatusCode != http . StatusOK { return nil , " " , fmt . Errorf ( " " , resp . Request . URL . String ( ) , resp . Status ) } return nil , " " , err } // Handle errors if response . Type == api . ErrorResponse { return nil , " " , fmt . Errorf ( response . Error ) } return & response , etag , nil }
// Internal functions
Internal functions