Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/presscorp/networkxi
Exquisite networking package for iOS
https://github.com/presscorp/networkxi
async-await ios networking swift web-socket
Last synced: about 7 hours ago
JSON representation
Exquisite networking package for iOS
- Host: GitHub
- URL: https://github.com/presscorp/networkxi
- Owner: presscorp
- License: mit
- Created: 2023-03-12T18:24:12.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-22T13:47:07.000Z (about 1 year ago)
- Last Synced: 2024-04-25T05:42:44.733Z (7 months ago)
- Topics: async-await, ios, networking, swift, web-socket
- Language: Swift
- Homepage:
- Size: 50.8 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# NetworkXI
### Exquisite networking package for iOS (version >= 13.0)
## List of features
- NetworkXI utilizes fundamental `URLSession` under the hood
- NetworkXI exclusively takes advantage of *Async/await* approach for request making
- All interactions with NetworkXI are based on protocols, so you can make your own implementations of
`NetworkSessionInterface`, `NetworkService`
- NetworkXI provides logger that prints beautifully crafted request/response events into *Xcode* console
- NetworkXI provides the opportunity to renew session by updating authorization
- NetworkXI supports SSL certificate pinning along with default challenge
- NetworkXI supports easily implemented response mocking
- NetworkXI supports response caching feature
- NetworkXI supports separate implementation (`WebSocketSessionInterface`, `WebSocketService`) of web-socket message
exchange
## Example of use
#### Creating URL list
```Swift
import NetworkXIstruct HttpbinOrgURL: RequestURLExtensible {
let path: String
var host: String { "httpbin.org" }
}extension HttpbinOrgURL {
static let uuid = Self("/uuid")
}```
#### Describing request
```Swift
import NetworkXIclass UUIDRequest: NetworkRequest {
var url: RequestURL { HttpbinOrgURL.uuid }
var method: RequestMethod { .GET }
var encoding: RequestContentEncoding { .url }
}```
#### Making the request
```Swift
import NetworkXI// Create session interface and use it across the app
let sessionAdapter = NetworkSessionAdapter()
sessionAdapter.defaultSSLChallengeEnabled = true// Work with a new instance of network service
let worker = NetworkWorker(sessionInterface: sessionAdapter)let request = UUIDRequest()
let response = await worker.make(request)if response.success,
let body = response.jsonBody,
let uuidString = body["uuid"] as? String {
print("UUID: " + uuidString)
}
```
## License
**NetworkXI** is released under the **MIT** license