summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2016-10-12 16:33:59 +0200
committerGitHub <noreply@github.com>2016-10-12 16:33:59 +0200
commitb77fb67fee2aca5dabbcfb6aff8cef0607ede9d0 (patch)
tree708c173d167e0d0f094c37cffb1d410d25bf4355
parente6ff6dd9c89b3156fe50f61f6a28bcaba4aca91c (diff)
parent72b15678a1f66a8683034e30fefa51969a7ac4d5 (diff)
downloadNim-b77fb67fee2aca5dabbcfb6aff8cef0607ede9d0.tar.gz
Merge pull request #4887 from alphashuro/patch-2
Add example for posting json content
-rw-r--r--lib/pure/httpclient.nim14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/pure/httpclient.nim b/lib/pure/httpclient.nim
index 4404a9426..bfeb9a52e 100644
--- a/lib/pure/httpclient.nim
+++ b/lib/pure/httpclient.nim
@@ -50,6 +50,20 @@
 ##
 ##   echo client.postContent("http://validator.w3.org/check", multipart=data)
 ##
+## You can also make post requests with custom headers. 
+## This example sets ``Content-Type`` to ``application/json``
+## and uses a json object for the body
+##
+## .. code-block:: Nim
+##   import httpclient, json
+##   
+##   let client = newHttpClient()
+##   client.headers = newHttpHeaders({ "Content-Type": "application/json" })
+##   let body = %*{
+##       "data": "some text"
+##   }
+##   echo client.request("http://some.api", httpMethod = HttpPost, body = $body)
+##
 ## Progress reporting
 ## ==================
 ##