浏览代码

style(dataproxy): simplify expression

bergquist 9 年之前
父节点
当前提交
9ece10ef24
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      pkg/api/dataproxy.go

+ 1 - 1
pkg/api/dataproxy.go

@@ -109,7 +109,7 @@ func ProxyDataSourceRequest(c *middleware.Context) {
 	proxyPath := c.Params("*")
 
 	if ds.Type == m.DS_PROMETHEUS {
-		if !(c.Req.Request.Method == "GET" && strings.Index(proxyPath, "api/") == 0) {
+		if c.Req.Request.Method != http.MethodGet || !strings.HasPrefix(proxyPath, "api/") {
 			c.JsonApiErr(403, "GET is only allowed on proxied Prometheus datasource", nil)
 			return
 		}