Adds  compression middleware if enable
package api
import (
+ "github.com/NYTimes/gziphandler"
log "github.com/Sirupsen/logrus"
"github.com/hellofresh/janus/pkg/cors"
"github.com/hellofresh/janus/pkg/middleware"
@@ -81,6 +82,12 @@ func (m *Loader) RegisterApi(referenceSpec *Spec) {
log.Debug("OAuth2 is not enabled")
}
+ if referenceSpec.UseCompression {
+ handlers = append(handlers, gziphandler.GzipHandler)
+ } else {
+ log.Debug("Compression is not enabled")
+ }
+
m.register.Add(proxy.NewRoute(referenceSpec.Proxy, handlers...))
log.Debug("API registered")
} else {
