add client config

This commit is contained in:
Tanner Nelson 2016-09-29 19:41:38 -04:00
parent 2d5d8e5614
commit 7a84e63fb7
No known key found for this signature in database
GPG Key ID: 9C24375C64856B76
1 changed files with 19 additions and 12 deletions

View File

@ -53,6 +53,25 @@ For example:
try drop.client.request(.other(method: "CUSTOM"), "http://some-domain", headers: ["My": "Header"], query: ["key": "value"], body: [])
```
## Config
The `Config/clients.json` file can be used to modify the client's settings.
### TLS
Host and certificate verification can be disabled.
> Note: Use extreme caution when modifying these settings.
```json
{
"tls": {
"verifyHost": false,
"verifyCertificates": false
}
}
```
## Advanced
In addition to our Droplet, we can also use and interact with the `Client` manually. Here's how our default implementation in Vapor looks:
@ -116,15 +135,3 @@ Going forward, all of your calls to `drop.client` will use `MyCustomClient.self`
```swift
drop.client.get(... // uses `MyCustomClient`
```
### Provider
We can also use Providers to inherit behavior in our application. For example, to add Linux compatible TLS to our application's `Client`, we might use this:
```swift
import VaporTLS
let drop = Droplet(initializedProviders: [VaporTLS.Provider(.client)])
```
In the same way as above, this will now apply to all `drop.client` calls within our application.