Swiftpack.co - bteapot/Server as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by bteapot.
bteapot/Server 1.0.8
Lightweight ReactiveSwift dynamically configurable network layer.
⭐️ 3
🕓 2 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/bteapot/Server.git", from: "1.0.8")

Server

Lightweight ReactiveSwift dynamically configurable network layer.

Overview

This small library provides solution for most modern Swift application's networking needs. It designed to be dependable on application user's state, dynamically changing it's configuration and request parameters on user authorization or other environment changes. Information exchange – encoding of outgoing data, setting of corresponding request headers, checking response code, decoding received data – is done through single method.

Making a request would be as simple as:

Server.back
    .request(
        type: .post,
        path: "/ping"
    )
    .start()

Or as complex as:

Server.back
    .request(
        type: .post,
        path: "/userinfo",
        query: [
            "id": userID,
        ],
        send: .multipart([
            .png(avatarImage, name: "avatar", filename: "avatar.png"),
            .text(firstName, name: "first_name"),
            .text(lastName, name: "last_name"),
        ]),
        take: .json(UserCard.self)
    )
    .reportError(title: "Can't update user card")
    .observe(on: QueueScheduler.main)
    .startWithValues { userCard in
        // process updated user card
    }

Documentation

Complete Xcode documentation is included with code and its archived version attached to GitHub release page.

Documentation is also available online.

GitHub

link
Stars: 3
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

General configuration simplification
2 weeks ago

URLSession moved into Config structure. – Server.assets replaced by Server.config. – SessionConfiguration replaced with direct use of URLSessionConfiguration. – Session configuration and authentication challenge handler are no longer stored in Config.

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