adding gzip.
This commit is contained in:
@@ -21,18 +21,34 @@
|
|||||||
[ring.adapter.jetty :refer [run-jetty]]
|
[ring.adapter.jetty :refer [run-jetty]]
|
||||||
[yang.scheduler :as scheduler]
|
[yang.scheduler :as scheduler]
|
||||||
[com.unbounce.dogstatsd.core :as statsd])
|
[com.unbounce.dogstatsd.core :as statsd])
|
||||||
(:import org.eclipse.jetty.server.handler.StatisticsHandler))
|
(:import [org.eclipse.jetty.server.handler.gzip GzipHandler]
|
||||||
|
[org.eclipse.jetty.server.handler StatisticsHandler]))
|
||||||
|
|
||||||
(defn add-shutdown-hook! [^Runnable f]
|
(defn add-shutdown-hook! [^Runnable f]
|
||||||
(.addShutdownHook (Runtime/getRuntime)
|
(.addShutdownHook (Runtime/getRuntime)
|
||||||
(Thread. f)))
|
(Thread. f)))
|
||||||
|
|
||||||
|
|
||||||
|
(defn gzip-handler []
|
||||||
|
(doto (GzipHandler.)
|
||||||
|
(.setIncludedMimeTypes (into-array ["text/css"
|
||||||
|
"text/plain"
|
||||||
|
"text/javascript"
|
||||||
|
"text/csv"
|
||||||
|
"application/javascript"
|
||||||
|
"application/csv"
|
||||||
|
"application/edn"
|
||||||
|
"application/json"
|
||||||
|
"image/svg+xml"]))
|
||||||
|
(.setMinGzipSize 1024)))
|
||||||
|
|
||||||
(defn configure-jetty [server]
|
(defn configure-jetty [server]
|
||||||
(let [stats-handler (StatisticsHandler.)
|
(let [stats-handler (StatisticsHandler.)
|
||||||
|
gzip-handler (gzip-handler)
|
||||||
default-handler (.getHandler server)]
|
default-handler (.getHandler server)]
|
||||||
(.setHandler stats-handler default-handler)
|
|
||||||
|
(.setHandler gzip-handler default-handler)
|
||||||
|
(.setHandler stats-handler gzip-handler)
|
||||||
(.setHandler server stats-handler))
|
(.setHandler server stats-handler))
|
||||||
(.setStopAtShutdown server true))
|
(.setStopAtShutdown server true))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user