Ring is a Clojure web applications library inspired by Python's WSGI and Ruby's Rack. By abstracting the details of HTTP into a simple, unified API, Ring allows web applications to be constructed of modular components that can be shared among a variety of applications, web servers, and web frameworks.
The SPEC file at the root of this distribution for provides a complete description of the Ring interface.
Synopsis
A "Hello World" in Ring handler:
(use 'ring.adapter.jetty)
(defn app [req]
{:status 200
:headers {"Content-Type" "text/html"}
:body "Hello World from Ring"})
(run-jetty app {:port 8080})
If you request http://localhost:8080/ in your browser the ring.handler.dump handler will respond with an HTML page representing the request map that it received (see the SPEC for details on the request map).
If you request http://localhost:8080/clojure.png, the ring.middleware.file middleware will detect that there is a clojure.png file in the app's public directory and return that image as a response.
If you request http://localhost:8080/error, the app will produce an error that will be caught by the ring.middleware.stacktrace middleware, which will in turn return a readable stacktrace as the HTML response.
Available Libraries
ring-core
ring.middleware.file: Serve static files out of a public directory.
ring.middleware.static: Serve static files with specified prefixes out of a public directory.
ring.middleware.file-info: Augment response headers with info about File responses.
ring.middleware.params: Parse query and form params.
* If you request `http://localhost:8080/` in your browser the `ring.handler.dump` handler will respond with an HTML page representing the request map that it received (see the `SPEC` for details on the request map).
* If you request `http://localhost:8080/clojure.png`, the `ring.middleware.file` middleware will detect that there is a `clojure.png` file in the app's `public` directory and return that image as a response.
0 comments on commit
8ca2df9