QueryService: Move raw http.Handler to rest.Connector (#87595)

* query connector

* improve error wrappers

* return 400 for missing datasource (not 404)

* fix errors

* message
This commit is contained in:
Ryan McKinley
2024-05-10 21:01:17 +03:00
committed by GitHub
parent f43ed7e6d7
commit f880abc292
4 changed files with 225 additions and 160 deletions
+7 -1
View File
@@ -26,14 +26,20 @@ import (
"github.com/grafana/grafana/pkg/apiserver/endpoints/filters"
)
// TODO: this is a temporary hack to make rest.Connecter work with resource level routes
var pathRewriters = []filters.PathRewriter{
{
// TODO: this is a temporary hack to make rest.Connecter work with resource level routes
Pattern: regexp.MustCompile(`(/apis/scope.grafana.app/v0alpha1/namespaces/.*/find$)`),
ReplaceFunc: func(matches []string) string {
return matches[1] + "/name" // connector requires a name
},
},
{
Pattern: regexp.MustCompile(`(/apis/query.grafana.app/v0alpha1/namespaces/.*/query$)`),
ReplaceFunc: func(matches []string) string {
return matches[1] + "/name" // connector requires a name
},
},
}
func SetupConfig(