Fork me on GitHub
#pedestal
<
2020-04-08
>
this.rob17:04:05

i’ve noticed that if I set a lazy seq as the body on the context’s response, and that lazy seq involves side effects (e.g. debug printlns) they are included in the body, presumably because pedestal calls pr-str on the body before returning it:

(def println-test
  {:name :println-test
   :enter
   (fn [context]
     (assoc context :response {:status 200
                               :body (map #(do (println "FOO")
                                               %)
                                          (range 0 3))}))})
If I hit an endpoint hooked up to that interceptor I get this back:
{:status 200, :body "(FOO\nFOO\nFOO\n0 1 2)"}
Am I doing something wrong? I would like the body to be EDN.

hindol17:04:53

map and println should not be mixed like that.