A Ring adapter for Eclipse Vert.x 5, providing a bridge between Clojure's Ring specification and Vert.x's reactive HTTP server.
This library allows you to run Ring applications on Vert.x, taking advantage of Vert.x's high-performance, reactive, and non-blocking I/O capabilities while maintaining compatibility with the Ring ecosystem.
- Ring-compliant request/response handling
- Asynchronous request processing
- Integration with Vert.x's event loop
- Support for Ring middleware
- Configurable server options
This adapter implements the Ring SPEC, providing:
- Request Map: HTTP requests are converted to Clojure maps with standard Ring keys
- Response Map: Ring response maps are converted back to HTTP responses
- Handler Function: Standard Ring handler function interface
- Middleware Support: Compatible with existing Ring middleware
- Clojure 1.12.0+
- Vert.x Core 5.0.4
- Ring Core 1.13.0
(require '[com.p14n.vertx-ring.adapter :as adapter])
(defn handler [request respond raise]
(respond {:status 200
:headers {"Content-Type" "text/plain"}
:body "Hello, World!"}))
(adapter/run-server handler {:port 8080})(require '[com.p14n.vertx-ring.adapter :as adapter])
(import '[java.util.concurrent Executors])
(defn handler [request]
{:status 200
:headers {"Content-Type" "text/plain"}
:body "Hello, World!"})
(adapter/run-server handler {:port 8080
:executor (Executors/newCachedThreadPool)})For more control over Vert.x behavior, you can use the options helpers:
(require '[com.p14n.vertx-ring.adapter :as adapter]
'[com.p14n.vertx-ring.options :as options])
(defn handler [request respond raise]
(respond {:status 200
:headers {"Content-Type" "text/plain"}
:body "Hello, World!"}))
;; Configure Vert.x options
(def vertx-opts (options/map->vertx-options
{:event-loop-pool-size 4
:worker-pool-size 20
:prefer-native-transport true}))
;; Configure HTTP server options
(def server-opts (options/map->http-server-options
{:port 8080
:host "0.0.0.0"
:compression-supported true
:tcp-keep-alive true
:idle-timeout 30}))
(adapter/run-server handler {:vertx-options vertx-opts
:server-options server-opts}):event-loop-pool-size- Number of event loop threads:worker-pool-size- Number of worker threads:prefer-native-transport- Use native transport when available:ha-enabled- Enable high availability:blocked-thread-check-interval- Thread blocking check interval
:port- Server port (default 8080):host- Server host (default "localhost"):compression-supported- Enable HTTP compression:tcp-keep-alive- Enable TCP keep-alive:ssl- Enable SSL/TLS:idle-timeout- Connection idle timeout:max-websocket-frame-size- Maximum WebSocket frame size
- Clone this repository
- Start a REPL:
clj -M:dev - In the REPL:
(require 'user) (user/start) ; Starts server on port 8080
- Test with curl:
curl http://localhost:8080/ - Stop the server:
(user/stop)
See the examples/ directory for more usage examples.
Build a JAR:
clj -T:build jarRun tests:
clj -M:testThis project uses Clojure CLI tools with deps.edn.
clj -M:replclj -M:testCopyright © 2025
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.