浏览代码

Data source proxy: Fixed issue with Gzip enabled and data source proxy, Fixes #1675

Torkel Ödegaard 10 年之前
父节点
当前提交
c3fa68ade8
共有 3 个文件被更改,包括 23 次插入1 次删除
  1. 1 0
      CHANGELOG.md
  2. 2 1
      pkg/cmd/web.go
  3. 20 0
      pkg/middleware/util.go

+ 1 - 0
CHANGELOG.md

@@ -1,6 +1,7 @@
 # 2.0.0-RC1  (unreleased)
 # 2.0.0-RC1  (unreleased)
 
 
 **FIxes**
 **FIxes**
+- [Issue #1675](https://github.com/grafana/grafana/issues/1675). Data source proxy: Fixed issue with Gzip enabled and data source proxy
 - [Issue #1681](https://github.com/grafana/grafana/issues/1681). MySQL session: fixed problem using mysql as session store
 - [Issue #1681](https://github.com/grafana/grafana/issues/1681). MySQL session: fixed problem using mysql as session store
 - [Issue #1671](https://github.com/grafana/grafana/issues/1671). Data sources: Fixed issue with changing default data source (should not require full page load to take effect, now fixed)
 - [Issue #1671](https://github.com/grafana/grafana/issues/1671). Data sources: Fixed issue with changing default data source (should not require full page load to take effect, now fixed)
 - [Issue #1685](https://github.com/grafana/grafana/issues/1685). Search: Dashboard results should be sorted alphabetically
 - [Issue #1685](https://github.com/grafana/grafana/issues/1685). Search: Dashboard results should be sorted alphabetically

+ 2 - 1
pkg/cmd/web.go

@@ -42,8 +42,9 @@ func newMacaron() *macaron.Macaron {
 	m := macaron.New()
 	m := macaron.New()
 	m.Use(middleware.Logger())
 	m.Use(middleware.Logger())
 	m.Use(macaron.Recovery())
 	m.Use(macaron.Recovery())
+
 	if setting.EnableGzip {
 	if setting.EnableGzip {
-		m.Use(macaron.Gziper())
+		m.Use(middleware.Gziper())
 	}
 	}
 
 
 	mapStatic(m, "", "public")
 	mapStatic(m, "", "public")

+ 20 - 0
pkg/middleware/util.go

@@ -0,0 +1,20 @@
+package middleware
+
+import (
+	"strings"
+
+	"github.com/Unknwon/macaron"
+)
+
+func Gziper() macaron.Handler {
+	macaronGziper := macaron.Gziper()
+
+	return func(ctx *macaron.Context) {
+		requestPath := ctx.Req.URL.RequestURI()
+		if strings.HasPrefix(requestPath, "/api/datasources/proxy") {
+			return
+		}
+
+		ctx.Invoke(macaronGziper)
+	}
+}