Releases: 3lvis/Networking
Networking — 4.1.0
Added a way to extract the data from the response of a GET, POST, PUT, DELETE request. Before you would be able to access the JSON as dictionary or array, now you can also access the data. This is useful for example if you want to use Networking with JSONDecoder
.
let networking = Networking(baseURL: "http://httpbin.org")
networking.get("/get") { result in
switch result {
case let .success(response):
// response.dictionaryBody -> JSON
// response.data -> JSON data
case .failure:
// Handle error
}
}
In order to achieve this in a clean way I had to modify the JSON enum, while doing this I noticed that the JSON enum was public, it wasn't meant to be public so I've converted it into a protected enum. The biggest breaking change of doing this is that some projects might be making use of the JSON.from(:bundle:)
method, now you can access this utility using FileManager.json(from:bundle:)
.
Networking — 4.0.0
Xcode 9 and Swift 4 support!
Breaking changes
- Renamed
disableErrorLogging
toisErrorLoggingEnabled
- Changed initializer to use
URLSessionConfiguration
instead of the customConfigurationType
.
Before
let networking = Networking(baseURL: "http://httpbin.org", configurationType: .default)
After
var configuration = URLSessionConfiguration.default
configuration.timeoutIntervalForRequest = TimeInterval(60)
configuration.timeoutIntervalForResource = TimeInterval(6048000)
let networking = Networking(baseURL: "http://httpbin.org", configuration: configuration)
Networking — 3.0.3
- Update to Swift 3.1 (Xcode 8.3)
Networking — 3.0.2
- Added convenience accessor for the result's error #197
Useful for when you don't care about the result but more if there's an error or not.
Before:
networking.delete("/user/10") { result in
switch result {
case .success:
completion(nil)
case .failure(let response):
completion(response.error)
}
}
Now:
networking.delete("/user/10") { result in
completion(result.error) // NSError?
}
Networking — 3.0.1
- Fix result crashing when the request was successful but the image or data were malformed. #196
Networking — 3.0.0
After 3 months of 2.0.0 we have refined Networking, refactored the internals, improved the unit tests and now we're ready to delete all the deprecated methods and make the big jump to 3.0.0.
Here are the things that you need to change in order to use Networking 3.
Networking — 3.0.0 (Beta 3)
- Refactored internals, cleaned up a few methods
Networking — 3.0.0 (Beta 2)
Changes from Beta 1
Merged the error and the HTTPURLResponse into one object for each Result case.
Previously
After 3 months of 2.0.0 we have refined Networking, refactored the internals, improved the unit tests and now we're ready to delete all the deprecated methods and make the big jump to 3.0.0.
Here are the things that you need to change in order to use Networking 3.
Networking — 3.0.0 (Beta 1)
After 3 months of 2.0.0 we have refined Networking, refactored the internals, improved the unit tests and now we're ready to delete all the deprecated methods and make the big jump to 3.0.0.
Here are the things that you need to change in order to use Networking 3.
Networking — 2.8.0
- Moved all methods to use lowercase instead of uppercase to follow Swift 3 guidelines
// Before
networking.GET(....)
networking.POST(....)
networking.PUT(....)
networking.DELETE(....)
// After
networking.get(....)
networking.post(....)
networking.put(....)
networking.delete(....)
- Documented disabling error logging
let networking = Networking(baseURL: "http://httpbin.org")
networking.disableErrorLogging = true
- Add support for synchronous networking
let networking = Networking(baseURL: "http://httpbin.org")
networking.isSynchronous = true