mirror of
https://github.com/grafana/grafana.git
synced 2024-11-23 09:26:43 -06:00
6e7c18fc1c
* pkg/middleware: Check errors * pkg/middleware: Log when gzip middleware handler fails
35 lines
693 B
Go
35 lines
693 B
Go
package middleware
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/go-macaron/gzip"
|
|
"github.com/grafana/grafana/pkg/infra/log"
|
|
"gopkg.in/macaron.v1"
|
|
)
|
|
|
|
func Gziper() macaron.Handler {
|
|
gziperLogger := log.New("gziper")
|
|
gziper := gzip.Gziper()
|
|
|
|
return func(ctx *macaron.Context) {
|
|
requestPath := ctx.Req.URL.RequestURI()
|
|
// ignore datasource proxy requests
|
|
if strings.HasPrefix(requestPath, "/api/datasources/proxy") {
|
|
return
|
|
}
|
|
|
|
if strings.HasPrefix(requestPath, "/api/plugin-proxy/") {
|
|
return
|
|
}
|
|
|
|
if strings.HasPrefix(requestPath, "/metrics") {
|
|
return
|
|
}
|
|
|
|
if _, err := ctx.Invoke(gziper); err != nil {
|
|
gziperLogger.Error("Invoking gzip handler failed", "err", err)
|
|
}
|
|
}
|
|
}
|