mirror of
https://github.com/grafana/grafana.git
synced 2025-07-29 07:23:09 +08:00
Plugins: Introduce HTTP 207 Multi Status response to api/ds/query (#48550)
* feature toggles * return HTTP 207 from ds/query * add ft check * add API test * add 207 check for qr * change to OR * revert check * add explicit toggle check for cloudwatch * remove unused import * remove from defaults.ini * add status codes to md and update swagger * new fangled http api tests pattern * update swagger * Update docs/sources/http_api/data_source.md Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com> * add missing word and reformat Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
This commit is contained in:
@ -31,7 +31,7 @@ func (hs *HTTPServer) QueryMetricsV2(c *models.ReqContext) response.Response {
|
||||
if err != nil {
|
||||
return hs.handleQueryMetricsError(err)
|
||||
}
|
||||
return toJsonStreamingResponse(resp)
|
||||
return hs.toJsonStreamingResponse(resp)
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) handleQueryMetricsError(err error) *response.NormalResponse {
|
||||
@ -147,7 +147,7 @@ func (hs *HTTPServer) QueryMetricsFromDashboard(c *models.ReqContext) response.R
|
||||
if err != nil {
|
||||
return hs.handleQueryMetricsError(err)
|
||||
}
|
||||
return toJsonStreamingResponse(resp)
|
||||
return hs.toJsonStreamingResponse(resp)
|
||||
}
|
||||
|
||||
// QueryMetrics returns query metrics
|
||||
@ -198,11 +198,16 @@ func (hs *HTTPServer) QueryMetrics(c *models.ReqContext) response.Response {
|
||||
return response.JSON(statusCode, &legacyResp)
|
||||
}
|
||||
|
||||
func toJsonStreamingResponse(qdr *backend.QueryDataResponse) response.Response {
|
||||
func (hs *HTTPServer) toJsonStreamingResponse(qdr *backend.QueryDataResponse) response.Response {
|
||||
statusWhenError := http.StatusBadRequest
|
||||
if hs.Features.IsEnabled(featuremgmt.FlagDatasourceQueryMultiStatus) {
|
||||
statusWhenError = http.StatusMultiStatus
|
||||
}
|
||||
|
||||
statusCode := http.StatusOK
|
||||
for _, res := range qdr.Responses {
|
||||
if res.Error != nil {
|
||||
statusCode = http.StatusBadRequest
|
||||
statusCode = statusWhenError
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user