Swiftpack.co -  Package - bryanbarreto/easy-request
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
bryanbarreto/easy-request
Swift Package Manager for http requests
.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 weeks ago

Release Notes

Version 1.0
3 weeks ago

First version for EasyRequest

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