Skip to content
weavejester edited this page Aug 13, 2011 · 12 revisions

You can create Ring response maps manually (see Concepts), but the ring.util.response namespace contains a number of useful function to make this task easier.

The response function creates a basic "200 OK" response:

(response "Hello World")

=> {:status 200
    :headers {}
    :body "Hello World"}

You can then use functions like content-type to alter the base response to add in additional headers and other components:

(-> (response "Hello World")
    (content-type "text/plain"))

=> {:status 200
    :headers {"Content-Type" "text/plain"}
    :body "Hello World"}
Clone this wiki locally