Ast3r10n/swiftquests
An object-oriented, URLSession-based network library.
Installation
Swift Package Manager
Add a Swift Package Dependency to your project with URL:
https://github.com/Ast3r10n/swiftquestsCocoapods
Add SwiftQuests to your Podfile:
pod 'SwiftQuests'Usage
A Request is a basic, standalone object, with a single associated task, configured through its initialiser. Once initialised, a Request is (for the most part) immutable. Its task will only launch through the perform method call.
Basic Request
To perform a basic Request, initialise one:
do {
let request = try Request(.get,
atPath: "/user")
} catch {
// Error handling
}You then call the perform method to launch its associated task.
do {
try request.perform { result in
// Response implementation
}
} catch {
// Error handling
}Decodable object Request
Requests support automatic JSON decoding using Decodable objects
Here's an example Request to get a Decodable User object from the /user endpoint.
do {
try Request(.get,
atPath: "/user")
.perform(decoding: User.self) { result in
// Your completion handler here
}
} catch {
// Error handling
}Package Metadata
Repository: Ast3r10n/swiftquests
Stars: 3
Forks: 0
Open issues: 2
Default branch: develop
Primary language: swift
License: GPL-3.0
Topics: network, package, swift, urlsession
README: README.md