Skip to content
This repository
Browse code

Ensure that `render` retains the metadata on any provided response map

  • Loading branch information...
commit 087cbe97f72bb302c7d760625eb4c21d165a4fa8 1 parent 24fe43a
Chas Emerick cemerick authored committed
3  src/compojure/response.clj
@@ -20,7 +20,8 @@
20 20 (content-type "text/html; charset=utf-8")))
21 21 APersistentMap
22 22 (render [resp-map _]
23   - (merge (response "") resp-map))
  23 + (merge (with-meta (response "") (meta resp-map))
  24 + resp-map))
24 25 IFn
25 26 (render [func request]
26 27 (render (func request) request))
7 test/compojure/test/response.clj
@@ -40,4 +40,9 @@
40 40 (testing "with stream URL"
41 41 (let [response (response/render (io/resource "ring/util/response.clj") {})]
42 42 (is (instance? InputStream (:body response)))
43   - (is (.contains (slurp (:body response)) "(ns ring.util.response")))))
  43 + (is (.contains (slurp (:body response)) "(ns ring.util.response"))))
  44 +
  45 + (testing "with map + metadata"
  46 + (let [response (response/render ^{:has-metadata? true} {:body "foo"} {})]
  47 + (is (= (:body response) "foo"))
  48 + (is (= (meta response) {:has-metadata? true})))))

0 comments on commit 087cbe9

Please sign in to comment.
Something went wrong with that request. Please try again.