浏览代码

Added Gzip option and the macaron Gzip middleware, but does not seem to work

Torkel Ödegaard 11 年之前
父节点
当前提交
166ce7d2ae
共有 3 个文件被更改,包括 6 次插入0 次删除
  1. 1 0
      conf/grafana.ini
  2. 3 0
      pkg/cmd/web.go
  3. 2 0
      pkg/setting/setting.go

+ 1 - 0
conf/grafana.ini

@@ -9,6 +9,7 @@ http_addr =
 http_port = 3000
 router_logging = false
 static_root_path = public
+enable_gzip = false
 
 [session]
 ; Either "memory", "file", default is "memory"

+ 3 - 0
pkg/cmd/web.go

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

+ 2 - 0
pkg/setting/setting.go

@@ -56,6 +56,7 @@ var (
 	CertFile, KeyFile  string
 	RouterLogging      bool
 	StaticRootPath     string
+	EnableGzip         bool
 
 	// Http auth
 	Anonymous          bool
@@ -164,6 +165,7 @@ func NewConfigContext() {
 
 	StaticRootPath = Cfg.MustValue("server", "static_root_path", path.Join(WorkDir, "webapp"))
 	RouterLogging = Cfg.MustBool("server", "router_logging", false)
+	EnableGzip = Cfg.MustBool("server", "enable_gzip")
 
 	// Http auth
 	Anonymous = Cfg.MustBool("auth", "anonymous", false)