2015-04-01 02:00:17 -05:00
|
|
|
package middleware
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2016-01-13 08:11:23 -06:00
|
|
|
"github.com/go-macaron/gzip"
|
2016-01-13 08:38:54 -06:00
|
|
|
"gopkg.in/macaron.v1"
|
2015-04-01 02:00:17 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func Gziper() macaron.Handler {
|
2016-01-13 08:11:23 -06:00
|
|
|
macaronGziper := gzip.Gziper()
|
2015-04-01 02:00:17 -05:00
|
|
|
|
|
|
|
return func(ctx *macaron.Context) {
|
|
|
|
requestPath := ctx.Req.URL.RequestURI()
|
2015-04-07 06:48:26 -05:00
|
|
|
// ignore datasource proxy requests
|
2015-04-01 02:00:17 -05:00
|
|
|
if strings.HasPrefix(requestPath, "/api/datasources/proxy") {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2016-06-02 02:56:53 -05:00
|
|
|
if strings.HasPrefix(requestPath, "/api/plugin-proxy/") {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2015-04-01 02:00:17 -05:00
|
|
|
ctx.Invoke(macaronGziper)
|
|
|
|
}
|
|
|
|
}
|