I've been reading the edn spec and want to integrate it into my application. However, I don't know how to transfer edn requests between clojure and client. Do we put a content-type application/edn in the response header and just send the prn output string?
-
3Maybe this project by fogus can give you a starting point or some guidance: [ring-edn](https://github.com/fogus/ring-edn). – juan.facorro Jun 12 '13 at 21:04
-
See also [ring-middleware-format](https://github.com/ngrunwald/ring-middleware-format). – noahlz Jun 13 '13 at 15:58
1 Answers
Although it has not yet been accepted by IANA (June 14, 2013), the correct content-type is application/edn
. To provide a valid string output of your clojure object, use (pr-str obj)
. For a web service, the method of encoding and decoding depends on your web framework and your needs.
Pedestal supports parsing of edn into an :edn-params
key on its request map through the use of its body-params
interceptor. Sending clojure objects as edn is handled automatically if your response bodies are not strings. For content-negotiation, see pedestal-content-negotiation.
For ring middleware, ring-edn parses edn into an :edn-params
key, but does not do any outbound modification. ring-middleware-format provides parsing of a handful of different formats into the :body-params
key, and has a collection of middlewares that can be helpful for responses as well. There are a handful of other ring middleware projects like this out there.

- 3,334
- 2
- 26
- 42