Skip to content

Repository files navigation

SessionPlus

A swift request & response framework for JSON apis.

This package has been designed to work across multiple swift environments by utilizing conditional checks. It has been tested on Apple platforms (macOS, iOS, tvOS, watchOS), as well as Linux (Ubuntu).

Usage

SessionPlus offers a default implementation (URLSessionClient) that allows for requesting data from a JSON api. For example:

leturl=URL(string:"https://api.agify.io")!
letclient=BaseURLSessionClient(baseURL: url)letrequest=Get(queryItems:[URLQueryItem(name:"name", value:"bob")])letresponse=tryawait client.request(request)

Decoding

The Client protocol also offers extensions for automatically decoding responses to any Decodable type.

structApiResult:Decodable{letname:Stringletage:Intletcount:Int}letresponse=tryawait client.request(request)asApiResult...letresponse:ApiResult=tryawait client.request(request)

Installation

SessionPlus is distributed using the Swift Package Manager. You can add it using Xcode or by listing it as a dependency in your Package.swift manifest:

letpackage= Package(...
dependencies:[.package(url:"https://github.com/richardpiazza/SessionPlus.git",.upToNextMajor(from:"2.0.0")],...
targets:[.target(
name:"MyPackage",
dependencies:[.product(name:"SessionPlus",package:"SessionPlus"),])])

Contribution

Contributions to SessionPlus are welcomed and encouraged! See the Contribution Guide for more information.

About

A swift request & response framework for JSON apis.

Topics

Resources

Code of conduct

Contributing

Stars

2 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages