util.go 391 B

12345678910111213141516171819202122
  1. package middleware
  2. import (
  3. "strings"
  4. "github.com/go-macaron/gzip"
  5. "gopkg.in/macaron.v1"
  6. )
  7. func Gziper() macaron.Handler {
  8. macaronGziper := gzip.Gziper()
  9. return func(ctx *macaron.Context) {
  10. requestPath := ctx.Req.URL.RequestURI()
  11. // ignore datasource proxy requests
  12. if strings.HasPrefix(requestPath, "/api/datasources/proxy") {
  13. return
  14. }
  15. ctx.Invoke(macaronGziper)
  16. }
  17. }