Chore: Moves common and response into separate packages (#30298)
* Chore: moves common and response into separate packages * Chore: moves common and response into separate packages * Update pkg/api/utils/common.go Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Chore: changes after PR comments * Chore: move wrap to routing package * Chore: move functions in common to response package * Chore: move functions in common to response package * Chore: formats imports Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
co-authored by
Arve Knudsen
parent
a94c256516
commit
3d41267fc4
+6
-5
@@ -4,12 +4,13 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/grafana/grafana/pkg/api/response"
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
func AdminGetSettings(c *models.ReqContext) Response {
|
||||
func AdminGetSettings(c *models.ReqContext) response.Response {
|
||||
settings := make(map[string]interface{})
|
||||
|
||||
for _, section := range setting.Raw.Sections() {
|
||||
@@ -35,15 +36,15 @@ func AdminGetSettings(c *models.ReqContext) Response {
|
||||
}
|
||||
}
|
||||
|
||||
return JSON(200, settings)
|
||||
return response.JSON(200, settings)
|
||||
}
|
||||
|
||||
func AdminGetStats(c *models.ReqContext) Response {
|
||||
func AdminGetStats(c *models.ReqContext) response.Response {
|
||||
statsQuery := models.GetAdminStatsQuery{}
|
||||
|
||||
if err := bus.Dispatch(&statsQuery); err != nil {
|
||||
return Error(500, "Failed to get admin stats from database", err)
|
||||
return response.Error(500, "Failed to get admin stats from database", err)
|
||||
}
|
||||
|
||||
return JSON(200, statsQuery.Result)
|
||||
return response.JSON(200, statsQuery.Result)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user