planck

Planck ClojureScript REPL
henrik 2019-02-02T07:41:01.008400Z

I'm trying to adjust settings on ElasticSearch with Planck. ElasticSearch wants a JSON blob on a PUT request. How would I format this appropriately with planck.http/put? This is the curl equivalent:

curl -XPUT '<http://localhost:9200/_cluster/settings>' -d '{… blob …}'

mfikes 2019-02-02T13:52:03.009700Z

@henrik If you do the following curl command (specifying JSON content type)

curl -XPUT '<http://localhost:9200/_cluster/settings>' -H "Content-Type: application/json" -d '{:foo 1}'
then the equivalent in Planck would be:
(planck.http/put "<http://localhost:9200/_cluster/settings>" {:content-type "application/json" :body "{foo: 1}"})

mfikes 2019-02-02T13:55:26.011700Z

Otherwise, curl is actually sending a content-type of application/x-www-form-urlencoded, and in that case a curl request like

curl -XPUT '<http://localhost:9200/_cluster/settings>' -d 'foo=1'
has the following equivalent in Planck:
(http/put "<http://localhost:9200/_cluster/settings>" {:form-params {:foo 1}})
(But I suspect you really want to work with JSON given your description.)

henrik 2019-02-02T16:25:52.012600Z

Cool! I didn't see in the docs that you could set :body explicitly. Thank you!

henrik 2019-02-02T16:27:33.013200Z

Actually, my bad, it's in the spec.