From c3fa68ade85d2087b9aae3490a5e3e105486db8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 1 Apr 2015 09:00:17 +0200 Subject: [PATCH] Data source proxy: Fixed issue with Gzip enabled and data source proxy, Fixes #1675 --- CHANGELOG.md | 1 + pkg/cmd/web.go | 3 ++- pkg/middleware/util.go | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 pkg/middleware/util.go diff --git a/CHANGELOG.md b/CHANGELOG.md index ace3efcbe62..165f7b40253 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # 2.0.0-RC1 (unreleased) **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 #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 diff --git a/pkg/cmd/web.go b/pkg/cmd/web.go index 1fc6e8a999c..8d7697b9871 100644 --- a/pkg/cmd/web.go +++ b/pkg/cmd/web.go @@ -42,8 +42,9 @@ func newMacaron() *macaron.Macaron { m := macaron.New() m.Use(middleware.Logger()) m.Use(macaron.Recovery()) + if setting.EnableGzip { - m.Use(macaron.Gziper()) + m.Use(middleware.Gziper()) } mapStatic(m, "", "public") diff --git a/pkg/middleware/util.go b/pkg/middleware/util.go new file mode 100644 index 00000000000..2d7d9739ead --- /dev/null +++ b/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) + } +}