Elegant network abstraction layer in Swift.
Design
Alamofire and Moya are elegant Swift network frames. They each have their own advantages. When I use them, I always want to combine the advantages of both, make them easy to use and retain their original features. So I wrote the SolarNetwork.
- SLNetwork corresponds to a SessionManager.
- SLTarget corresponds to a Host, or a set of requests for the same configuration.
- SLRequest, SLDownloadRequest, SLUploadRequest corresponds to Request of Data, Download, Upload.
- SLProgress return progress when download or upload.
- SLResponse response of a request which you can decode to JsonObject or Model.
- SLPlugin you can modify SLRequest in
willSend
and modify SLResponse indidReceive
. - SLReflection reflex properties of SubSLRequest to Alamofire.Parameters.
So a complete request process is:
In most cases, what you need to concerned about is:
Features
- [x] URL / JSON / plist Parameter Encoding
- [x] Upload File / Data / Stream / MultipartFormData
- [x] Download File using Request or Resume Data
- [x] Authentication with URLCredential
- [x] Upload and Download Progress Closures with Progress
- [x] Dynamically Adapt and Retry Requests
- [x] TLS Certificate and Public Key Pinning
- [x] Network Reachability
- [x] Pre-populate the DNS cache
- [x] Complete Logger
Requirements
- iOS 8.0+
- Xcode 9+
- Swift 4+
Communication
- If you'd like to ask a general question, use Stack Overflow.
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
CocoaPods 1.1+ is required.
To integrate SolarNetwork into your Xcode project using CocoaPods, specify it in your Podfile
:
Then, run the following command:
Carthage
Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.
You can install Carthage with Homebrew using the following command:
To integrate Alamofire into your Xcode project using Carthage, specify it in your Cartfile
:
Run carthage update
If this is your first time using Carthage in the project, you'll need to go through some additional steps as explained over at Carthage.
Usage
Base Usage
Target
Request
Download
Upload
Decode
In Swift 4, you can use Codable.
License
Alamofire is released under the MIT license. See LICENSE for details.