feat(cloudwatch): contining work on moving hard coded stuff to backend and cleaning up code, #684

This commit is contained in:
Torkel Ödegaard
2015-10-02 11:54:35 +02:00
parent 180ba33ac8
commit 0912cec0e5
4 changed files with 195 additions and 287 deletions
+2 -15
View File
@@ -10,7 +10,6 @@ import (
"github.com/aws/aws-sdk-go/service/cloudwatch"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/grafana/grafana/pkg/middleware"
"github.com/grafana/grafana/pkg/util"
)
type actionHandler func(*cwRequest, *middleware.Context)
@@ -29,6 +28,8 @@ func init() {
"ListMetrics": handleListMetrics,
"DescribeInstances": handleDescribeInstances,
"__GetRegions": handleGetRegions,
"__GetNamespaces": handleGetNamespaces,
"__GetMetrics": handleGetMetrics,
}
}
@@ -122,20 +123,6 @@ func handleDescribeInstances(req *cwRequest, c *middleware.Context) {
c.JSON(200, resp)
}
func handleGetRegions(req *cwRequest, c *middleware.Context) {
regions := []string{
"us-west-2", "us-west-1", "eu-west-1", "eu-central-1", "ap-southeast-1",
"ap-southeast-2", "ap-northeast-1", "sa-east-1",
}
result := []interface{}{}
for _, region := range regions {
result = append(result, util.DynMap{"text": region, "value": region})
}
c.JSON(200, result)
}
func HandleRequest(c *middleware.Context) {
var req cwRequest
req.Body, _ = ioutil.ReadAll(c.Req.Request.Body)