From 30989a838aecc0467673926a220f7b38bf6c0113 Mon Sep 17 00:00:00 2001 From: Attila Magyar Date: Thu, 1 Jul 2021 12:07:38 +0200 Subject: [PATCH] Update README.md --- README.md | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 375176e..c8236f5 100644 --- a/README.md +++ b/README.md @@ -441,13 +441,46 @@ You can also specify HTTP headers by adding a `headers` key to the map. In this ```forth #[ - 'headers' #[ ]# + 'headers' #[ ]# 'content' #[ .. ]# ]# ``` +For example this will set the content type header to json and the body will be sent as a JSON object. + + +```forth +#[ + 'headers' #[ 'Content-Type' 'application/json' ] + 'content' #[ 'on' true 'xy' [ 0.3 0.4 ] 'transitiontime' 10 ]# +]# +``` + +A shorter way to do the same is to use `+json-type` on the map. + +```forth +#[ 'on' true 'xy' [ 0.3 0.4 ] 'transitiontime' 10 ]# +json-type +``` + + ### Examples +#### Controlling Philips Hue lights + + +```forth +: hue ( x y msec -- ) + 10 / rount -> t -> y -> x + 1 -> group-id + #[ + 'on' true + 'xy' [ x y ] + 'bri' 254 + 'transitiontime' t ( centiseconds ) + ]# +json-type + group-id 'http:///api//groups/1/action' http-put +; +``` #### Controlling a Daikin Air Conditioner ```forth