Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
kean committed Apr 9, 2022
1 parent e307886 commit ac5261d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
A modern Swift web API client built using async/await.

```swift
let client = APIClient(baseURL: URL(string: "https://api.github.com))
let client = APIClient(baseURL: URL(string: "https://api.github.com"))

// Using the client directly
let user: User = try await client.send(.get("/user")).value
Expand All @@ -28,13 +28,13 @@ let repos = try await client.send(Paths.users("kean").repos.get)
You start by instantiating a client:

```swift
let client = APIClient(baseURL: URL(string: "https://api.github.com))
let client = APIClient(baseURL: URL(string: "https://api.github.com"))
```

You can customize the client using `APIClient.Configuration` (see it for a complete list of available options). You can also use a convenience initializer to configure it inline:

```swift
let client = APIClient(baseURL: URL(string: "https://api.github.com)) {
let client = APIClient(baseURL: URL(string: "https://api.github.com")) {
$0.sessionConfiguration.httpAdditionalHeaders = ["UserAgent": "bonjour"]
$0.delegate = YourDelegate()
}
Expand Down Expand Up @@ -108,7 +108,7 @@ final class AuthorizingDelegate: APIClientDelegate {
`APIClient` provides elegant high-level APIs, but also gives you _complete_ access to the underlying `URLSession` APIs. You can, as shown earlier, change the session configuration, but it doesn't stop there. You can also provide a custom `URLSessionDelegate` and implement only the methods you are interested in – `APIClient` will handle the rest.

```swift
let client = APIClient(baseURL: URL(string: "https://api.github.com)) {
let client = APIClient(baseURL: URL(string: "https://api.github.com")) {
$0.sessionConfiguration.httpAdditionalHeaders = ["UserAgent": "bonjour"]
$0.sessionDelegate = YourSessionDelegate()
}
Expand All @@ -132,7 +132,7 @@ final class YourSessionDelegate: URLSessionTaskDelegate {
You can easily add logging to your API client using [Pulse](https://github.com/kean/Pulse). It's a one-line setup.

```swift
let client = APIClient(baseURL: URL(string: "https://api.github.com)) {
let client = APIClient(baseURL: URL(string: "https://api.github.com")) {
$0.sessionDelegate = PulseCore.URLSessionProxyDelegate()

// If you also have a session delegate, add it to the delegate chain
Expand Down

0 comments on commit ac5261d

Please sign in to comment.