From 6cead31707596598ff15d2eec9109e3423c75676 Mon Sep 17 00:00:00 2001 From: Casper Rasmussen Date: Thu, 12 Jan 2017 01:46:21 +0100 Subject: [PATCH 1/3] Updated with a form-data example --- http/client.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/http/client.md b/http/client.md index 7308fac1..e7632f6f 100644 --- a/http/client.md +++ b/http/client.md @@ -35,6 +35,17 @@ let bytes = myJSON.makeBytes() try drop.client.post("http://some-endpoint/json", headers: ["Auth": "Token my-auth-token"], body: .data(jsonBytes)) ``` +### Post as form-data +```swift +let result = try drop.client.post("http://some-endpoint", headers: [ + "Content-Type": "application/x-www-form-urlencoded" + ], body: Body.data( Node([ + "email": "mymail@vapor.codes" + ]).formURLEncoded())) + +``` + + ### Full Request To access additional functionality or custom methods, use the underlying `request` function directly. From e7e1f1696c1cc854c0ada1658f92c5f68d7446f0 Mon Sep 17 00:00:00 2001 From: Casper Rasmussen Date: Fri, 13 Jan 2017 19:45:52 +0100 Subject: [PATCH 2/3] Updated POST examples --- http/client.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/http/client.md b/http/client.md index e7632f6f..71f755d7 100644 --- a/http/client.md +++ b/http/client.md @@ -30,14 +30,15 @@ try drop.client.get("https://api.spotify.com/v1/search", query: ["type": "artist In addition to `GET` requests, Vapor's client provides support for most common HTTP functions. `GET`, `POST`, `PUT`, `PATCH`, `DELETE` +### POST as json ```swift let bytes = myJSON.makeBytes() try drop.client.post("http://some-endpoint/json", headers: ["Auth": "Token my-auth-token"], body: .data(jsonBytes)) ``` -### Post as form-data +### POST as x-www-form-urlencoded ```swift -let result = try drop.client.post("http://some-endpoint", headers: [ +try drop.client.post("http://some-endpoint", headers: [ "Content-Type": "application/x-www-form-urlencoded" ], body: Body.data( Node([ "email": "mymail@vapor.codes" From a4a59a77d14b34a6e7fc0f89b6071b3e0f023fb5 Mon Sep 17 00:00:00 2001 From: Casper Rasmussen Date: Fri, 13 Jan 2017 19:51:52 +0100 Subject: [PATCH 3/3] updated comments --- http/client.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/http/client.md b/http/client.md index 71f755d7..7e59a180 100644 --- a/http/client.md +++ b/http/client.md @@ -39,14 +39,12 @@ try drop.client.post("http://some-endpoint/json", headers: ["Auth": "Token my-au ### POST as x-www-form-urlencoded ```swift try drop.client.post("http://some-endpoint", headers: [ - "Content-Type": "application/x-www-form-urlencoded" - ], body: Body.data( Node([ - "email": "mymail@vapor.codes" - ]).formURLEncoded())) - + "Content-Type": "application/x-www-form-urlencoded" +], body: Body.data( Node([ + "email": "mymail@vapor.codes" +]).formURLEncoded())) ``` - ### Full Request To access additional functionality or custom methods, use the underlying `request` function directly.