sunng87 /ring-jetty9-adapter
An enhanced version of jetty adapter for ring, with additional features like websockets, http/2 and http/3
★ 299⑂ 51👁 6⑃ 114● 66▤ 38
+0
日增长
299
stars
51
forks
6
watchers
114
prs
66
issues
38
releases
README
ring-jetty9-adapter (rj9a)
Ring adapter for Jetty 12 and 11 (although named as jetty9), with HTTP/2,
WebSocket, experimental HTTP/3 and virtual threads support.
This is a simple and plain wrapper on modern Jetty versions. It
doesn't introduce additional thread model or anything else (no
unofficial ring variance, no core.async). You are free to add those on
top of our base API. This library can be used as a drop-in replacement
of original ring-jetty-adapter.
As of Ring 1.6, the official Jetty adapter has been updated to Jetty
9.2. However, rj9a tracks most recent Jetty release and offers
additional features like http/2, http/3 and websocket.
Version Matrix
rj9a works on top of certain components of Java/Clojure ecosystem. To find a
version works for your stack, check the version matrix below.
| rj9a | Jetty | JDK | Clojure | Servlet API | Ring API | Maintained? |
| --- | --- | --- | --- | --- | --- | --- |
| HEAD | 12.1.x | 17 | 1.12 | N/A | 1.15 | true |
| 0.33.x | 12.0.x | 17 | 1.11 | N/A | 1.12 | false |
| 0.32.x | 12.0.x | 17 | 1.11 | N/A | 1.11 | false |
| 0.30.x | 12.0.x | 17 | 1.11 | N/A | 1.10 | false |
| 0.22.x | 11.0.x | 11 | 1.11 | Jakarta 5.0 | 1.10 | false |
| 0.17.x | 10.0.x | 11 | 1.10 | Jakarta 4.0 | 1.9 | false |
| 0.14.x | 9.4.x | 8 | 1.10 | 3.1 | 1.8 | false |
The master branch will keep tracking Jetty 12 as our default release
channel. Jetty versions prior to 12 have reached their EOF (support is only
available with commercial version), so now we are dropping support of them. But
you can still use it.
Note that from 0.33 of rj9a, we dropped dependencies to ring/ring-core and
only depend on their protocol artifacts. This won't be a problem if your
applications are just normal ring sync or async handlers. However, for websocket
users, you will need to include ring/ring-core explicitly as dependency to be
able to use websocket APIs.
For JDK 8 users, 0.14 releases should be usable but I'm no longer actively
maintaining it.
Usage
Leiningen
Code
In the REPL:
clojure
(require '[ring.adapter.jetty9 :refer [run-jetty]])
(run-jetty app {:port 50505}) ;; same as the 'official' adapter
In ns declaration:
clojure
(ns my.server
(:require [ring.adapter.jetty9 :refer [run-jetty]]))
Ring 1.6 async handler
clojure
(require '[ring.adapter.jetty9 :refer [run-jetty]])
(defn app [request send-response raise-error]
(send-response {:body "It works!"}))
(run-jetty app {:port 50505 :async? true})
HTTP/2
HTTP/2 becomes an optional feature since rj9a 0.35, to enable HTTP/2 on
cleartext and secure transport, first you need to add our optional dependency:
[info.sunng/ring-jetty9-adapter-http2 "VERSION"]
VERSION can be checked
here
Second, provide HTTP/2 options to run-jetty like:
clojure
(jetty/run-jetty dummy-app {:port 5000
:h2c? true ;; enable cleartext http/2
:h2? true ;; enable http/2
:ssl? true ;; ssl is required for hTop issues
#63Server-sent events support7 comments · 2021-12-17#122`write-body-to-stream` does not behave like in ring.adapter.jetty6 comments · 2024-01-10#104c10k problem in jdk 21 with virtual threads. 6 comments · 2023-08-07#133ABORTED triggered by repeated video elements with ring-jetty9-adapter <= 0.17.82 comments · 2024-04-16#142Unix domain socks support0 comments · 2024-10-25#132Web transport server-side API0 comments · 2024-04-05
Latest release
0.40.6 0.40.6 2026-11-03What's Changed Fix/binary receive callback by @eneroth in https://github.com/sunng87/ring-jetty9-adapter/pull/179 Full Changelog: https://github.com/sunng87/ring-jetty9-adapter/compare/0.40.5...0.40.6