Created
September 5, 2014 19:14
-
-
Save danneu/dce2ec9e46362875c014 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def app-routes | |
;; Echo back the json | |
(POST "/lol" req | |
(let [json (:body req) ; wrap-json-body parses the json into a clojure map | |
] | |
;; Now we echo back the json map. wrap-json-response converts our `json` | |
;; clojure map into a string | |
{:body json, :status 200}))) | |
(def app | |
(-> app-routes | |
(handler/site) | |
(ring.middleware.json/wrap-json-body) | |
(ring.middleware.json/wrap-json-response))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RestClient.post("http://localhost:3000/lol", | |
{:id => "peat", :label => "Peat Bakke", :attributes => [{:for => "attribute_name", :value => 1}, {:for => "something_else", :value => "wee"}]}.to_json, | |
:content_type => :json) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment