util.go 371 B

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