Skip to content

A framework built on top of URLSession to enable writing URLRequest in a declarative syntax to make it more readable and expressive (yes, pun definitely intended) and reduce unwanted mutability.

License

Notifications You must be signed in to change notification settings

ahmedfathy-m/URLExpress

Repository files navigation

URLExpress

CI Status Version License Platform Swift Package Manager Swift 5.7 GitHub repo size

URLExpress is a framework built on top of URLSession to enable declarative syntax for URLRequests to reduce unwanted mutability and increase readability.

Features

  • Declarative Syntax
  • URL / JSON Parameter Encoding
  • Multipart Request Support
  • Easy Access for request's headers and parameters
  • Combine Support
  • Support for iOS 13.0+
  • Compatibility for Cocoapods and Swift Package Manager
  • RxSwift support (coming soon)
  • Tracking Upload/Download Progress
  • HTTP Response Validation
  • Network Reachability

Requirements

  • iOS 13.0 or higher
  • If you're using reactive programming, stick with Combine for now.
  • Support for RxSwift will be added in the future.

Installation

Cocoapods

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

pod 'URLExpress'

Swift Package Manager

  • You can access the package manager interface from File > Add Package and copying the repository link to the search bar https://github.com/ahmedfathy-m/URLExpress.git and press Add Package when you're done

  • Alternatively, you can add URLExpress as a dependency by adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/ahmedfathy-m/URLExpress.git", .upToNextMajor(from: "0.1.0"))
]

Usage

URLExpress allows you to chain multiple commands as you would in Combine or SwiftUI to produce declarative code that reduces unwanted mutability and side effects.

        URL(domain: "https://dummyjson.com", path: "auth/login")!
            .makeRequest(with: .post)
            .appendingTextField("username", value: "kminchelle")
            .appendingTextField("password", value: "0lelplR")
            .withContentType(.json)
            .withAcceptType(.json)
            .decodeJSONOnReceive(for: Login.self)
            .send {
                print($0)
            } success: {
                print("Welcome, \($0.firstName) \($0.lastName)")
            }

For detailed instructions on how to use URLExpress in multiple case check the documentation.

Developer

  • URLExpress is developed and maintained by me personally.
  • If you have any questions or suggestions about URLExpress, don't hesitate to send me an email: ahmedfathy.mha@gmail.com

License

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

About

A framework built on top of URLSession to enable writing URLRequest in a declarative syntax to make it more readable and expressive (yes, pun definitely intended) and reduce unwanted mutability.

Resources

License

Stars

Watchers

Forks

Packages

No packages published