EasyRequest is a Swift library for dealing with Http Requests.
Use the Swift Package Manager to install EasyRequest.
https://github.com/bryanbarreto/easy-request
import EasyRequest
/* create url with EasyRequest helper function: withPercentEncoding */
guard let url = URL.withPercentEncoding(string: "https://jsonplaceholder.typicode.com/todos") else {
return
}
/* create a short Resource object */
let shortResource = Resource<SomeModel>(url: url)
/* or a complete Resource */
let completeResource = Resource<SomeModel>(
url: url,
httpMethod: .get,
httpBody: Data(),
headers: ["Content-Type":"application/json"],
debugPrint: true
)
/* Now, just make a request */
WebService.shared.request(resource: resource, success: { (result) in
//success
print(result)
}) { (error) in
//error
print(error.rawValue)
print(error.localizedDescription)
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
link |
Stars: 1 |
Last commit: 3 years ago |
First version for EasyRequest
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics