Fork me on GitHub
#pedestal
<
2021-04-18
>
Franco Gasperino22:04:16

hello all. using the interceptor body-params, i'm able to accept a post verb with a json body as edn as documented. Im i wrong to expect an end assoc map structure, with the Content-Type header set, should also be handled in the response by the same inteceptor (:leave) ?

(def test
  {:name :test
   :enter
   (fn [context]
     (let [request (:request context)
           {:keys [headers json-params]} request]
       (assoc context :response
          {:status 200
           :body json-params
           :headers {"Content-Type" "application/json"}})))})

(def common [(body-params)])
(def test-interceptor (conj common test))

(def routes
  #{["/test" :post test-interceptor :route-name :test]})

Franco Gasperino22:04:12

The HTTP response in the client has the Content-Type set to "application/json", but the body of the response is still edn: {:key "value"}

Franco Gasperino22:04:00

My assumption is that body-params on :leave will stringify-keys or such