yada

2017-10-18T22:59:41.000054Z

I have another puzzle here - how can I make a :post request to yada with a body? Here is my attempt:

(let [body  "[\"^ \",\"~:foo\",\"a-string\"]"  ;; (util/clj->t {:foo "a-string"})
      c    (pr-str (count (.getBytes body)))   ;; 25
      ]
  ;; interestingly for content-length 0 it returns 400
  (yada/response-for
    (yada/resource {:methods {:post {:consumes [{:media-type #{"application/transit+json"}
                                                 :charset "UTF-8"}]
                                     :produces [{:media-type #{"application/transit+json"}
                                                 :charset "UTF-8"}]
                                     :parameters {:body {:foo s/Str}}
                                     :response (fn [ctx]
                                                 ;; how to get
                                                 ;; parameters here?
                                                 {:parameters   (:parameters ctx)})}}})
    :post
    "ignore-me"
    {:headers {"accept" "application/transit+json"
               "content-length" c}
     :body body}))
;; returns
;; {:status 415, :headers {"content-length" "0"}, :body nil}
;;