-
Notifications
You must be signed in to change notification settings - Fork 6
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")))
TODO
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:
-
:encoding
The character encoding of the parameters. Acts the same as the same option inwrap-params
. -
:store
A 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