Oct 15, 2024
- Fix Swift 6 warnings
Apr 13, 2024
- Increase the minimum supported Xcode version to 14.3
- Fix warnings in unit tests
Dec 25, 2022
Nov 2, 2022
- Fix warnings in Xcode 14.1
- Move docc files back to the Sources/
Oct 22, 2022
- Fix xcodebuild & docc issue in Xcode 14.0
Oct 8, 2022
- Fix #53, a concurrency warning with strict concurrency checking
Sep 21, 2022
- Fix an issue with
withResponse
always setting method to.get
- #62, thanks to @briancordanyoung
Sep 20, 2022
- Fix concurrency issue in
DataLoader
with the new iOS 16didCreateTask
delegate method
Sep 17, 2022
- Add support for optional responses. If the response is optional and the response body is empty, the request will now succeed and return
nil
- #58, thanks to @Pomanks
Sep 13, 2022
- Add support for Xcode 14 (fix build issue on macOS)
Aug 26, 2022
This release is a quick follow-up to Get 1.0 that fixes some of the shortcomings of the original design of the Request
type.
Request
can now be initialized with either a string (path: String
) or a URL (url: URL
)- Replace separate
.get(...)
,.post(...)
, and other factory methods with a singleHTTPMethod
type. Example:Request(path: "/user", method: .patch)
- The first parameter in the
Request
initializer is nowpath
orurl
, notmethod
that has a default value - Add a new
Request
initializer that defaults to theVoid
response type unless you specify it explicitly - Make
body
property ofRequest
writable - Add
upload(for:data:)
method - #50, thanks to @soemarko - Replace
APIDelegate
client(_:makeURLFor:query:)
method withclient(_:makeURLForRequest:)
so that you have complete access to theRequest
- Remove APIs deprecated in Get 1.0
See #51 for the reasoning behind the
Request
changes
Sep 20, 2022
- Fix concurrency issue in
DataLoader
with the new iOS 16didCreateTask
delegate method
Sep 13, 2022
- Add Xcode 14 support
Aug 3, 2022
- Revert back to supporting Swift 5.5 by @liamnichols in #47
Jul 26, 2022
- Add
@discardableResult
to allupload()
andsend()
methods
Jul 26, 2022
Get 1.0 is a big release that brings it on par with Moya+Alamofire while still keeping its API surface small and focused. This release also includes new reworked documentation generated using DocC, and many other improvements.
The first major change is the addition of two new parameters the existing send
method: delegate
and configure
:
public func send<T: Decodable>(
_ request: Request<T>,
delegate: URLSessionDataDelegate? = nil,
configure: ((inout URLRequest) -> Void)? = nil
) async throws -> Response<T>
With delegate
, you can modify the behavior of the underlying task, monitor the progress, etc. And with the new configure
closure, you get access to the entire URLRequest
API:
let user = try await client.send(.get("/user")) {
$0.cachePolicy = .reloadIgnoringLocalCacheData
}
The second major change is the addition of new methods: upload(...)
for uploading data from a file and download(...)
for downloading data to a file.
let response = try await client.download(for: .get("/user"))
let fileURL = response.location
try await client.upload(for: .post("/avatar"), fromFile: fileURL)
pulse-2.0
- Add a
delegate
parameter tosend()
method that sets task-specificURLSessionDataDelegate
- #38 - Add
configure
parameter tosend()
method that allows configuringURLRequest
before it is sent - Add support for downloading to a file with a new
download(for:delegate:configure:)
method - #40 - Add support for uploading data from a file with a new
upload(for:withFile:delegate:configure:)
method - Add an option to do more than one retry attempt using the reworked
client(_:shouldRetryRequest:attempts:error:)
delegate method (the method with an old signature is deprecated) - Add
client(_:validateResponse:data:request:)
toAPIClientDelegate
that allows to customize validation logic - Add
client(_:makeURLForRequest:)
method toAPIClientDelegate
to address #35 - Add
task
,originalRequest
,currentRequest
toResponse
- Add
APIClient/makeURLRequest(for:)
method to the client in case you need to createURLRequest
without initiating the download - Add a way to override
Content-Type
andAccept
headers using sessionhttpAdditionalHeaders
andRequest
headers - Add new
Request
factory methods that default toVoid
as a response type and streamline the existing methods - Add
withResponse(_:)
to allow changing request's response type - Add
sessionDelegateQueue
parameter toAPIClient.Configuration
- Add support for
sessionDelegate
fromAPIClient.Configuration
on Linux - Add public
configuration
andsession
properties toAPIClient
- Rename
Request/path
toRequest/url
making it clear that absolute URLs are also supported - Improve decoding/encoding performance by using
Task.detached
instead of using a separate actor for serialization - Remove send() -> Response<T?> variant
- Remove APIs deprecated in previous versions
- Fix an issue with paths that don't start with
"/"
not being appended to thebaseURL
- Fix an issue with empty path not working. It is now treated the same way as "/"
- Hide dependencies used only in test targets
- Documentation is now generated using DocC and is hosted on GitHub Pages
- Perform grammar check on CI
Apr 26, 2022
- Make
Request
andResponse
conditionallySendable
(requires Xcode 13.3) - Deprecate
URLRequest
cURLDescription()
extension – it was never meant to be in scope
Apr 11, 2022
- Fix trailing
?
when creating the request with empty query items - #29, thanks to Guilherme Souza
Apr 9, 2022
- Add
baseURL
client configuration option. Deprecatehost
,port
, andisInsercure
.
Usage:
APIClient(baseURL: URL(string: "https://api.github.com"))
Apr 3, 2022
- Add
URLRequest
parameter toshouldClientRetry(_:request:withError:)
inAPIClientDelegate
- #23, thanks to Pavel Krusek - Add Linux support - #20, thanks to Mathieu Barnachon
Jan 21, 2022
- Make
APIClientDelegate
method throwable - #16, thanks to Tomoya Hayakawa
Jan 10, 2022
- Add public
Request
initializer
Dec 29, 2021
- The new optional
send()
variant now also supportsString
, andData
.
Dec 29, 2021
- Add
send
variant that works with optional types. If the response is empty – returnnil
.
Dec 24, 2021
- Remove
value(for:)
. It's not a great convenience method if it requires the same amount of code as an regular version.
let user: User = try await client.send(.get("/user")).value
let user: User = try await client.value(for: .get("/user"))
Dec 23, 2021
- It now supports iOS 13, macOS 10, watchOS 6, and tvOS 13
- Make
willSend
async - #11, thanks to Lars-Jørgen Kristiansen - Add a more convenient way to initialize
APIClient
(same asImagePipeline
in Nuke):
let client = APIClient(host: "api.github.com") {
$0.delegate = MyClientDelegate()
$0.sessionConfiguration.httpAdditionalHeaders = ["apiKey": "easilyExtractableSecretKey"]
}
- You can now provide a session delegate (
URLSessionDelegate
) when instantiating a client for monitoring URLSession events – the client will continue doing its thing - Add metrics (
URLSessionTaskMetrics
) toResponse
- Add public
Response
initializer and make properties writable
Dec 13, 2021
- Method
send
now supports fetchingResponse<Data>
(returns raw data) andResponse<String>
(returns plain text) - Query parameters are now modeled as an array of
(String, String?)
tuples enabling "explode" support - You can now pass
headers
in the request - Body in
post
,put
, andpatch
can now be empty - All methods now support query parameters
- Add
body
parameter todelete
method - Make
body
parameter optional
Dec 10, 2021
- Make
Configuration
init public - #10, thanks to @theisegeberg - All
send
methods now return a newResponse<T>
struct containing not just the response value, but also data, request, response, and status code. - Add
value(for:)
method that returnsT
– a replacement for the oldsend
method - Add
data(for:)
method returningResponse<Data>
- Add
options
,head
, andtrace
HTTP methods - Method
delete
to usequery
instead ofbody
Dec 8, 2021
- Add an option to customize the client's port and scheme - #7, thanks to Mathieu Barnachon
- Make values in query parameters optional - #8, thanks to Bernhard Loibl
- Update example JSON models to match the GitHub API spec - #5, thanks to Arthur Semenyutin
- Use
iso8601
date decoding and encoding strategies by default and add a way to customize the decoder and encoder - Add
id
to requests - Make
Request
properties public
Nov 28, 2021
- Make it available on more platforms
Nov 23, 2021
- Initial release