Skip to content

Commit

Permalink
Merge branch 'main' of github.com:dankinsoid/swift-api-client
Browse files Browse the repository at this point in the history
  • Loading branch information
dankinsoid committed Mar 12, 2024
2 parents 459b1d3 + 373bc5b commit b578c1a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ let client = APIClient(url: baseURL)
.bodyDecoder(.json(dateDecodingStrategy: .iso8601))
.bodyEncoder(.json(dateEncodingStrategy: .iso8601))
.errorDecoder(.decodable(APIError.self))
.tokenRefresher { client, _ in
try await client("token").get()
} auth: {
.bearer(token: $0)
}

// Create a `APIClient` instance for the /users path
let usersClient = client("users")
Expand Down Expand Up @@ -77,7 +82,7 @@ Executing an operation on the client involves:
All built-in extensions utilize these modifiers.
## Built-in `APIClient` Extensions
### Request building
Numerous methods exist for modifying a `URLRequest` such as `query`, `body`, `header`, `headers`, `method`, `path`, `timeout`, `cachePolicy`, `body`, `bodyStream` and more.\
Numerous methods exist for modifying a `URLRequest` such as `query`, `body`, `header`, `headers`, `method`, `path`, `timeout`, `cachePolicy`, `body`, `bodyStream` and more.
```swift
let client = APIClient(url: baseURL)
.method(.post)
Expand Down Expand Up @@ -142,7 +147,7 @@ Custom content serializers can be specified by passing a `ContentSerializer` ins
allowing the injection of an authentication type for all requests and enabling/disabling it for specific requests.

The `.auth` configuration is an `AuthModifier` instance with several built-in `AuthModifier` types:
- `.bearer(token)` for Bearer token authentication.
- `.bearer(token:)` for Bearer token authentication.
- `.basic(username:password:)` for Basic authentication.
- `.apiKey(key:field:)` for API Key authentication.

Expand Down

0 comments on commit b578c1a

Please sign in to comment.