GooseNet

A tiny vanilla async networking convenience pod using GCD and dataTask


License
MIT
Install
pod try GooseNet

Documentation

GooseNet

Version License: MIT Platform

This CocoaPods library is meant as a minimalistic async networking layer for reuse across projects to cut down on code repetition. Upcoming features include SSL-Pinning helpers for security concerns, request retrying, and webSocketTask and streamTask support.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

As shown in the Example app, the usage of the pod is as follows:

  1. Define a model that implements the Codable protocol for the data returned by your endpoint. In the case of the Example app:
public struct LegalDoc: Codable {
    let url: String
}
  1. Define an implementation of the ServiceRequest protocol. The ResponseModel must be assigned your Codable model that represents the data returned by your endpoint. Iin the case of the Example app's GetLegalDoc service request:
import GooseNet

struct GetLegalDoc: ServiceRequest {
    typealias ResponseModel = LegalDoc
    var EndpointDefinition: Endpoint {
    return Endpoint(baseUrl: "someTestBaseUrl.com", path: "/some/test/path")
}
  1. Call the Request method on the ServiceRequest implementation and handle the result. In the case of the Example app:
GetLegalDoc().Request { result in
    switch result {
        case .success(let legalDoc):
            print("legal doc url: \(legalDoc.url)")
        case .failure(let error):
            print("request failure with error: \(error)")
    }
}

Installation

GooseNet is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'GooseNet'

Author

Ali H. Shah, email: aviatoali@gmail.com, linkedin

License

GooseNet is available under the MIT license. See the LICENSE file for more info.