Skip to content

Commit

Permalink
🐛 Fixed url building to endpoint (QD-7958)
Browse files Browse the repository at this point in the history
  • Loading branch information
denispopesku authored and tiulpin committed Jan 22, 2024
1 parent 8d0947a commit 9f0c4ae
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ const (
)

func getCloudBaseUrl() string {
return fmt.Sprintf("https://%s", GetEnvWithDefault(QodanaEndpoint, DefaultEndpoint))
return GetEnvWithDefault(QodanaEndpoint, fmt.Sprintf("https://%s", DefaultEndpoint))
}

func getCloudApiBaseUrl() string {
return fmt.Sprintf("https://api.%s", GetEnvWithDefault(QodanaEndpoint, DefaultEndpoint))
return GetEnvWithDefault(QodanaEndpoint, fmt.Sprintf("https://api.%s", DefaultEndpoint))
}

// GetCloudTeamsPageUrl returns the team page URL on Qodana Cloud
Expand Down Expand Up @@ -126,20 +126,23 @@ func (client *QdClient) doRequest(path, method string, headers map[string]string
if responseErr != nil {
return RequestError{Err: responseErr}
}
defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {
log.Fatal(err)
}
}(resp.Body)

responseBody, _ := io.ReadAll(resp.Body)
if resp.StatusCode >= http.StatusOK && resp.StatusCode < http.StatusMultipleChoices {
var data map[string]interface{}
if err := json.Unmarshal(responseBody, &data); err != nil {
return RequestError{Err: err}
if resp != nil {
defer func(Body io.ReadCloser) {
err := Body.Close()
if err != nil {
log.Fatal(err)
}
}(resp.Body)

responseBody, _ := io.ReadAll(resp.Body)
if resp.StatusCode >= http.StatusOK && resp.StatusCode < http.StatusMultipleChoices {
var data map[string]interface{}
if err := json.Unmarshal(responseBody, &data); err != nil {
return RequestError{Err: err}
}
return Success{Data: data}
}
return Success{Data: data}
return APIError{StatusCode: resp.StatusCode, Message: string(responseBody)}
}
return APIError{StatusCode: resp.StatusCode, Message: string(responseBody)}
return APIError{StatusCode: 400, Message: "Wrong endpoint"}
}

0 comments on commit 9f0c4ae

Please sign in to comment.