util.go 466 B

1234567891011121314151617181920212223242526
  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. if strings.HasPrefix(requestPath, "/api/plugin-proxy/") {
  16. return
  17. }
  18. ctx.Invoke(macaronGziper)
  19. }
  20. }