Skip to content

netmelody/ring-simpleweb-adapter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ring-simpleweb-adapter

A ring adapter for the Simple HTTP Engine, commonly referred to as SimpleWeb.

Motivation

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.

Availability

The adapter is distributed via Clojars and can be included in your leiningen project.clj with:

[ring-simpleweb-adapter "0.2.0"]

Usage

(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)

Configuration

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
}

License

Copyright © 2012 Tom Denley

Distributed under the Apache2 License.

About

ring adapter for the simpleframework web server

Resources

License

Stars

Watchers

Forks

Packages

No packages published