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.1.1")

ApodiniAsyncHTTPClient

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 projects are welcome. Please make sure to read the contribution guidelines first.

License

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

GitHub

link
Stars: 0
Last commit: Yesterday

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.

Release Notes

0.1.1
1 week ago

Changes

  • Export AsyncHTTPClient import

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