Fork me on GitHub
#pedestal
<
2018-12-07
>
souenzzo17:12:55

There is a helper to make {:foo "bar"} => foo=bar to turn form-params into a "body string"?

souenzzo17:12:49

I think that I need a example of pedestal.test/response-for doing a HTTP POST with form-params

ccann20:12:44

here’s my rough example using peridot to construct the multipart headers and body

(require '[peridot.multipart :as multipart])


(let [{:keys [body headers]}        (multipart/build {:graphic (io/file "foo.bar")
                                                      :user-id 1})
      {:keys [status body headers]} (-> (::http/service-fn (http/create-servlet server/config))
                                        (response-for :post "/notes"
                                                      :body body
                                                      :headers headers)
                                        (decode))]
  (is (= 201 status))
  (is (= foo body)))

👍 4