A leightweigth HTTP client for Swift projects.
OkHttpClient supports Swift Package Manager.
To install OkHttpClient using Swift Package Manager you can follow the tutorial published by Apple using the URL for the OkHttpClient repo with the current version:
- In Xcode, select “File” → “Add Packages...”
- Enter https://github.com/rmichelberger/OkHttpClient
or you can add the following dependency to your Package.swift
:
.package(url: "https://github.com/rmichelberger/OkHttpClient/", from: "1.0.0")
func getItems() async throws -> [Item] {
let client = OkHttpClient()
let url = URL(...)
let request = URLRequest(url: url)
return try await client.execute(request)
}
You can specify the request and response logger.
let logger = SimpleLogger()
let client = OkHttpClient(logger: logger)
You can specify the data decoder. It's used to decode the response data.
The default is JSONDecoder
.
let decoder = Decoder()
let client = OkHttpClient(decoder: decoder)
- Improve unit test coverage.
- Improve documentation.
We always appreciate contributions from the community. Please make sure to cover your changes with unit tests.
Inspired by OkHttp.