Swiftpack.co - bryanbarreto/easy-request as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by bryanbarreto.
bryanbarreto/easy-request 1.0
Swift Package Manager for http requests
⭐️ 1
🕓 3 years ago
.package(url: "https://github.com/bryanbarreto/easy-request.git", from: "1.0")

EasyRequest

EasyRequest is a Swift library for dealing with Http Requests.

Installation

Use the Swift Package Manager to install EasyRequest.

https://github.com/bryanbarreto/easy-request

Usage

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)
}

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

GitHub

link
Stars: 1
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

Version 1.0
3 years ago

First version for EasyRequest

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics