In the Compojure application I'm working on, I have a Ring / Jetty adapter based on the ring-jetty-adapter that programmatically configures Jetty to use a GzipHandler for dynamic gzip content.
(defn- configurator [server ring-handler] (.setHandler server (doto (new HandlerCollection) (.addHandler (doto (new GzipHandler) (.setHandler (proxy-handler ring-handler)) (.setMimeTypes "text/html,text/plain,text/xml,application/xhtml+xml,text/css,application/javascript,text/javascript,image/svg+xml"))) (.addHandler (doto (new RequestLogHandler) (.setRequestLog (NCSARequestLog.)))))))
This function takes a Server instance and my Ring handler and installs it using some handlers. Note that GzipHandler
is a HandlerWrapper
, so it takes my (proxied) Ring handler and delegates it. I also add a log handler that will be executed after the ring handler (gzip-wrapped).
Check out the full working version .
source share