Swiftpack.co -  Package - avreolko/VCNetworking
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
avreolko/VCNetworking
Simple and declarative request builder
.package(url: "https://github.com/avreolko/VCNetworking.git", from: "1.3.1")

VCNetworking

A simple declarative builder for your network requests

Installation

Install with SPM 📦

Usage

let requestBuilder = RequestBuilder(baseURL: URL(string: "<some url>")!)

let request: Request<ResponseType> =
    requestBuilder
        .method(.get)
        .basicAuth(login: "login", pass: "pass")
        .headers(["key": "value"])
        .path("endpoint")
        .build()

request.start { result in
    switch result {
    case .success(let response): ()
    case .failure(let error): ()
    }
}

The request holds a strong reference to itself until a response. If you need lifecycle management for your async operations, you can use promises.

License

This project is released under the MIT license.

GitHub

link
Stars: 0
Last commit: 1 week ago

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