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
withResponsealways setting method to.get- #62, thanks to @briancordanyoung
Sep 20, 2022
- Fix concurrency issue in
DataLoaderwith the new iOS 16didCreateTaskdelegate 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.
Requestcan now be initialized with either a string (path: String) or a URL (url: URL)- Replace separate
.get(...),.post(...), and other factory methods with a singleHTTPMethodtype. Example:Request(path: "/user", method: .patch) - The first parameter in the
Requestinitializer is nowpathorurl, notmethodthat has a default value - Add a new
Requestinitializer that defaults to theVoidresponse type unless you specify it explicitly - Make
bodyproperty ofRequestwritable - Add
upload(for:data:)method - #50, thanks to @soemarko - Replace
APIDelegateclient(_: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
Requestchanges
Sep 20, 2022
- Fix concurrency issue in
DataLoaderwith the new iOS 16didCreateTaskdelegate 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
@discardableResultto 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
delegateparameter tosend()method that sets task-specificURLSessionDataDelegate- #38 - Add
configureparameter tosend()method that allows configuringURLRequestbefore 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:)toAPIClientDelegatethat allows to customize validation logic - Add
client(_:makeURLForRequest:)method toAPIClientDelegateto address #35 - Add
task,originalRequest,currentRequesttoResponse - Add
APIClient/makeURLRequest(for:)method to the client in case you need to createURLRequestwithout initiating the download - Add a way to override
Content-TypeandAcceptheaders using sessionhttpAdditionalHeadersandRequestheaders - Add new
Requestfactory methods that default toVoidas a response type and streamline the existing methods - Add
withResponse(_:)to allow changing request's response type - Add
sessionDelegateQueueparameter toAPIClient.Configuration - Add support for
sessionDelegatefromAPIClient.Configurationon Linux - Add public
configurationandsessionproperties toAPIClient - Rename
Request/pathtoRequest/urlmaking it clear that absolute URLs are also supported - Improve decoding/encoding performance by using
Task.detachedinstead 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
RequestandResponseconditionallySendable(requires Xcode 13.3) - Deprecate
URLRequestcURLDescription()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
baseURLclient configuration option. Deprecatehost,port, andisInsercure.
Usage:
APIClient(baseURL: URL(string: "https://api.github.com"))Apr 3, 2022
- Add
URLRequestparameter toshouldClientRetry(_:request:withError:)inAPIClientDelegate- #23, thanks to Pavel Krusek - Add Linux support - #20, thanks to Mathieu Barnachon
Jan 21, 2022
- Make
APIClientDelegatemethod throwable - #16, thanks to Tomoya Hayakawa
Jan 10, 2022
- Add public
Requestinitializer
Dec 29, 2021
- The new optional
send()variant now also supportsString, andData.
Dec 29, 2021
- Add
sendvariant 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
willSendasync - #11, thanks to Lars-Jørgen Kristiansen - Add a more convenient way to initialize
APIClient(same asImagePipelinein 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
Responseinitializer and make properties writable
Dec 13, 2021
- Method
sendnow 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
headersin the request - Body in
post,put, andpatchcan now be empty - All methods now support query parameters
- Add
bodyparameter todeletemethod - Make
bodyparameter optional
Dec 10, 2021
- Make
Configurationinit public - #10, thanks to @theisegeberg - All
sendmethods 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 oldsendmethod - Add
data(for:)method returningResponse<Data> - Add
options,head, andtraceHTTP methods - Method
deleteto usequeryinstead 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
iso8601date decoding and encoding strategies by default and add a way to customize the decoder and encoder - Add
idto requests - Make
Requestproperties public
Nov 28, 2021
- Make it available on more platforms
Nov 23, 2021
- Initial release