dataproxy: refactoring data source proxy to support route templates and wrote more tests for data proxy code, #9078

This commit is contained in:
Torkel Ödegaard
2017-08-23 10:52:31 +02:00
parent 63d6ab476a
commit 8bf49c51b9
6 changed files with 158 additions and 120 deletions
+9 -1
View File
@@ -6,6 +6,7 @@ import (
"github.com/grafana/grafana/pkg/metrics"
"github.com/grafana/grafana/pkg/middleware"
m "github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/plugins"
)
func getDatasource(id int64, orgId int64) (*m.DataSource, error) {
@@ -27,7 +28,14 @@ func ProxyDataSourceRequest(c *middleware.Context) {
return
}
// find plugin
plugin, ok := plugins.DataSources[ds.Type]
if !ok {
c.JsonApiErr(500, "Unable to find datasource plugin", err)
return
}
proxyPath := c.Params("*")
proxy := pluginproxy.NewDataSourceProxy(ds, c, proxyPath)
proxy := pluginproxy.NewDataSourceProxy(ds, plugin, c, proxyPath)
proxy.HandleRequest()
}