fix status code 200 (#47818)

This commit is contained in:
ying-jeanne
2022-04-15 08:01:58 -04:00
committed by GitHub
parent f263cad8ab
commit 7ddae870e7
44 changed files with 166 additions and 152 deletions
+4 -3
View File
@@ -2,6 +2,7 @@ package thumbs
import (
"context"
"net/http"
"github.com/grafana/grafana/pkg/api/response"
"github.com/grafana/grafana/pkg/models"
@@ -39,19 +40,19 @@ func (ds *dummyService) GetDashboardPreviewsSetupSettings(c *models.ReqContext)
func (ds *dummyService) StartCrawler(c *models.ReqContext) response.Response {
result := make(map[string]string)
result["error"] = "Not enabled"
return response.JSON(200, result)
return response.JSON(http.StatusOK, result)
}
func (ds *dummyService) StopCrawler(c *models.ReqContext) response.Response {
result := make(map[string]string)
result["error"] = "Not enabled"
return response.JSON(200, result)
return response.JSON(http.StatusOK, result)
}
func (ds *dummyService) CrawlerStatus(c *models.ReqContext) response.Response {
result := make(map[string]string)
result["error"] = "Not enabled"
return response.JSON(200, result)
return response.JSON(http.StatusOK, result)
}
func (ds *dummyService) Run(ctx context.Context) error {
+6 -5
View File
@@ -6,6 +6,7 @@ import (
"fmt"
"io"
"io/ioutil"
"net/http"
"time"
"github.com/grafana/grafana/pkg/api/response"
@@ -192,7 +193,7 @@ func (hs *thumbService) UpdateThumbnailState(c *models.ReqContext) {
}
hs.log.Info("Updated dashboard thumbnail state", "dashboardUid", req.UID, "theme", req.Theme, "newState", body.State)
c.JSON(200, map[string]string{"success": "true"})
c.JSON(http.StatusOK, map[string]string{"success": "true"})
}
func (hs *thumbService) GetImage(c *models.ReqContext) {
@@ -320,7 +321,7 @@ func (hs *thumbService) SetImage(c *models.ReqContext) {
return
}
c.JSON(200, map[string]int{"OK": len(fileBytes)})
c.JSON(http.StatusOK, map[string]int{"OK": len(fileBytes)})
}
func (hs *thumbService) StartCrawler(c *models.ReqContext) response.Response {
@@ -348,7 +349,7 @@ func (hs *thumbService) StartCrawler(c *models.ReqContext) response.Response {
return response.Error(500, "error starting", err)
}
return response.JSON(200, status)
return response.JSON(http.StatusOK, status)
}
func (hs *thumbService) StopCrawler(c *models.ReqContext) response.Response {
@@ -356,7 +357,7 @@ func (hs *thumbService) StopCrawler(c *models.ReqContext) response.Response {
if err != nil {
return response.Error(500, "error starting", err)
}
return response.JSON(200, msg)
return response.JSON(http.StatusOK, msg)
}
func (hs *thumbService) CrawlerStatus(c *models.ReqContext) response.Response {
@@ -364,7 +365,7 @@ func (hs *thumbService) CrawlerStatus(c *models.ReqContext) response.Response {
if err != nil {
return response.Error(500, "error starting", err)
}
return response.JSON(200, msg)
return response.JSON(http.StatusOK, msg)
}
// Ideally this service would not require first looking up the full dashboard just to bet the id!