-
Notifications
You must be signed in to change notification settings - Fork 1
Standard Library
The ring.util.response namespace contains functions for generating
responses. This can make your handlers more concise and
understandable.
In the last section the following example was used:
(defn what-is-my-ip [request]
{:status 200
:headers {"Content-Type" "text/plain"}
:body (:remote-addr request)})But by using the ring.util.response namespace, the function can be
written:
(defn what-is-my-ip [request]
(-> (response (:remote-addr request))
(content-type "text/plain")))The ring.util.request namespace defines functions for accessing some common parts of request maps.
Some examples are content-type, content-length, character-encoding. These all take the request map as their only argument.
URL-encoded parameters handle normal form data, but if you want to
upload files, you'll need multipart-encoded parameters. This
functionality can be added to your handler with the
wrap-multipart-params middleware.
(wrap-multipart-params handler)
(wrap-multipart-params handler options)The options for this middleware function are:
-
:encodingThe character encoding of the parameters. Acts the same as the same option inwrap-params. -
:storeA function to use to store the uploaded files. There are two stores included with Ring.
Multipart stores are covered in a later section.
TODO
TODO