Skip to content

Instantly share code, notes, and snippets.

@danneu
Created September 5, 2014 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danneu/dce2ec9e46362875c014 to your computer and use it in GitHub Desktop.
Save danneu/dce2ec9e46362875c014 to your computer and use it in GitHub Desktop.
(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)))
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