Swiftpack.co - helperbug/CodableRequest as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by helperbug.
helperbug/CodableRequest 0.0.1-alpha
CodableRequest is a Swift Package that wraps an async URLSession with a JSON Decoder and flattens out REST experience (requires Swift 5.5)
⭐️ 0
🕓 2 years ago
iOS macOS tvOS
.package(url: "https://github.com/helperbug/CodableRequest.git", from: "0.0.1-alpha")

CodableRequestLibrary

Helper class that makes it easy to use a REST endpoint with Swift's structured concurrency and codables. There is an implentation for GET that takes an address and decodes the resulting json into a Swift struct. There is a POST implementation that sends an encodable and receives a decoable.

Wrapping all that functionality means the caller has to deal with a large range of possible errors and exceptions. To unify the error path a wrapper Error is used that transcodes framework errors and also generates new types of errors when needed.

See the included test for example codable structs and a couple of tests.

MIT License

Copyright (c) 2021 Ben Waidhofer

Awaitable REST access where the results are decoded into the type specified by the caller.

Structured Generic GET

Caller passes in the codable object that is encoded into binary JSON and set as the http request's body. Results are decoded into the type specified by the caller.

Structured Generic POST

GitHub

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

Release Notes

Alpha Release 0.0.1
2 years ago

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