Swiftpack.co - Apodini/ApodiniAsyncHTTPClient as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Apodini/ApodiniAsyncHTTPClient
An Apodini extension to support the AsyncHTTPClient
.package(url: "https://github.com/Apodini/ApodiniAsyncHTTPClient.git", from: "0.3.1")

ApodiniAsyncHTTPClient

DOI codecov jazzy Build and Test

ApodiniAsyncHTTPClient extends Apodini with support for the AsyncHTTPClient to make HTTP requests in Handlers using the Environment: @Environment(\.httpClient) var httpClient: HTTPClient.
For more information about the AsyncHTTPClient check out the documentation fround in the AsyncHTTPClient repository at https://github.com/swift-server/async-http-client.

Requirements

ApodiniAsyncHTTPClient extends Apodini and can be added as an additional dependency to your Swift Package manifest (Package.swift):

dependencies: [
    .package(url: "https://github.com/Apodini/ApodiniAsyncHTTPClient.git", from: "0.1.0"),
    // And more Swift Package dependencies ...
],

You can use the dependency in your Apodini target as follows:

.target(
    name: "MyApodiniWebService",
    dependencies: [
        .product(name: "Apodini", package: "Apodini"),
        .product(name: "ApodiniAsyncHTTPClient", package: "ApodiniAsyncHTTPClient"),
        // And more dependencies for the target ...
    ]
),

Usage

You can use the AsyncHTTPClient to make HTTP requests in Handlers using the Environment: @Environment(\.httpClient) var httpClient: HTTPClient:

import Apodini
import ApodiniAsyncHTTPClient


struct CreateContact: Handler {
    @Environment(\.httpClient)
    var httpClient: HTTPClient
    
    
    func handle() throws -> EventLoopFuture<String> {
        httpClient
            .get(url: "https://github.com/Apodini/ApodiniAsyncHTTPClient")
            .map { response in
                guard response.status == .ok else {
                    return "❌"
                }
                return "ApodiniAsyncHTTPClient 🚀"
            }
    }
}

For more information about the AsyncHTTPClient check out the documentation fround in the AsyncHTTPClient repository at https://github.com/swift-server/async-http-client.

Contributing

Contributions to this project are welcome. Please make sure to read the contribution guidelines and the contributor covenant code of conduct first

License

This project is licensed under the MIT License. See License for more information.

GitHub

link
Stars: 0
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

0.3.1
4 weeks ago

Changes

  • Update to Apodini 0.5.0 @PSchmiedmayer (#10)
  • Update dependencies @ApodiniBot (#9)
  • Improve GitHub Action @PSchmiedmayer (#8)

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