Conduit is a type-safe, extendable networking library built on top of Alamofire and Promises. This page provides comprehensive guide about the Conduit library, which includes an overview, installation guides, feature details, and a tutorial to guide the user on how to use it.
Overview
Conduit brings together the power of Alamofire, a robust and elegant HTTP networking library in Swift, and the simplicity of Promises. This results in a network abstraction layer that is powerful, easy to use, and neatly integrated into any iOS, macOS, tvOS and watchOS applications.
Installation
Integrating Conduit into your project is simple with CocoaPods or Carthage.
CocoaPods
Add the following line to your Podfile:
pod 'Conduit'
Then run:
$ pod install
Carthage
Add this to your Cartfile:
github "Mindera/Conduit"
Then run:
$ carthage update
Features
- Cancellable requests
- Chainable request/response methods
- Syntax and development patterns following standards
- Improved error handling with Alamofire
- Convenience methods for request codification
- Upload/download tasks
Usage
The following example demonstrates how to create a GET request:
let apiClient = NetworkDataResourceService()
apiClient.fetchResource(ofType: SomeModel.self,
url: Environment.baseAPIURL.appendingPathComponent("resourcePath"),
method: .get)
.then { model in
print(model)
}
.catch { error in
print(error)
}
More detailed examples and tutorial for usage can be found in the official Conduit documentation.
Contributing
For those interested in contributing to the Conduit project, they can submit a pull request or create an issue on GitHub. Every contribution is much appreciated.
License
Conduit is available under the MIT license. Plenty of additional details can be found in the LICENSE file contained within the Conduit repository on GitHub.