Last active
August 16, 2021 22:49
-
-
Save martintrojer/841d6712a432380fe97c to your computer and use it in GitHub Desktop.
ring jetty gzip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns http-server | |
(:require [ring.adapter.jetty :as jetty]) | |
(:import [org.eclipse.jetty.server.handler.gzip GzipHandler])) | |
(defn- add-gzip-handler [server] | |
(.setHandler server | |
(doto (GzipHandler.) | |
(.setIncludedMimeTypes (into-array ["text/css" | |
"text/plain" | |
"text/javascript" | |
"application/javascript" | |
"application/json" | |
"image/svg+xml"])) | |
(.setMinGzipSize 1024) | |
(.setHandler (.getHandler server))))) | |
(defn start-server [app] | |
(let [server (jetty/run-jetty | |
app | |
(merge | |
{:port 8080 | |
:join? false | |
:configurator add-gzip-handler}))] | |
;; ... | |
)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defproject smaller-resources "0.1.0-SNAPSHOT" | |
:dependencies [ | |
;;; ... | |
[ring/ring-jetty-adapter "1.4.0" :exlcusions [org.eclipse.jetty/jetty-server]] | |
[org.eclipse.jetty/jetty-server "9.3.3.v20150827"]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment