A ring adapter for the Simple HTTP Engine, commonly referred to as SimpleWeb.
Simple provides a pure-Java HTTP server without using Servlets, and vastly outperforms most popular Java-based servers (see benchmarks).
This adapter aims to allow ring-based Clojure applications to quickly transition to SimpleWeb and experience the resulting performance improvements, as well as a reduction in artifact size.
The adapter is distributed via Clojars and can be included in your leiningen project.clj
with:
[ring-simpleweb-adapter "0.2.0"]
(use 'ring.adapter.simpleweb)
;; Define a basic ring handler
(defn handler [req]
{:status 200
:headers {"Content-Type" "text/html"}
:body "Hello world from SimpleWeb"})
;; Start the server on the specified port, returning a connection
(def connection (run-simpleweb handler {:port 8080}))
;; To stop the server, invoke .close method on the returned connection.
(.close connection)
The run-simpleweb
function accepts a ring handler
and an options
map. The supported options are as follows (with the specified default values):
{
:port 8181 ;; the port to listen on
:max-threads 50 ;; the maximum number of threads to use
}
Copyright © 2012 Tom Denley
Distributed under the Apache2 License.