@stijn generating a body from xml:
(extend-protocol yada.body/MessageBody
clojure.data.xml.Element
(to-body [cdxe representation]
(clojure.data.xml/emit-str cdxe))
(content-length [out]
nil ;; let default logic get length of string body
))
(defn make-server []
(yada/listener
["/" (yada/resource
{:methods
{:get
{:produces #{"application/xml"}
:response
(fn [ctx]
#clojure.data.xml.Element{:tag :p,
:attrs {},
:content ["hello "
#clojure.data.xml.Element{:tag :b,
:attrs {},
:content ["world"]}]})}}})]
{:port 3000}))
;; curl -vv "<http://localhost:3000>" -H "Accept: application/xml"
;; > GET / HTTP/1.1
;; > Accept: application/xml
;; >
;; < HTTP/1.1 200 OK
;; < Content-Type: application/xml
;; < content-length: 63
;; <
;; <?xml version="1.0" encoding="UTF-8"?><p>hello <b>world</b></p>