|
@@ -4,11 +4,10 @@ import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"net/http"
|
|
|
- "strings"
|
|
|
)
|
|
|
|
|
|
type DashboardResponse struct {
|
|
|
- Dashboard Dashboard `json:"user"`
|
|
|
+ Dashboard Dashboard `json:"dashboard"`
|
|
|
Errors []string `json:"errors"`
|
|
|
ErrorType string `json:"error_type"`
|
|
|
}
|
|
@@ -43,14 +42,10 @@ func GetDashboard(config APIConfig) (Dashboard, error) {
|
|
|
}
|
|
|
|
|
|
if response.StatusCode == http.StatusOK || response.StatusCode == http.StatusForbidden {
|
|
|
- var result *DashboardResponse
|
|
|
+ var result *Dashboard
|
|
|
json.NewDecoder(response.Body).Decode(&result)
|
|
|
|
|
|
- if result.ErrorType != "" {
|
|
|
- return Dashboard{}, fmt.Errorf("Failed to get discourse version. Error: %s", strings.Join(result.Errors, "; "))
|
|
|
- }
|
|
|
-
|
|
|
- return result.Dashboard, nil
|
|
|
+ return *result, nil
|
|
|
}
|
|
|
|
|
|
return Dashboard{}, fmt.Errorf("Unexpected response from discourse server at %s -- %s", url, response.Status)
|