t089 / smoke-http

Generic HTTP client for Swift applications

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build - Master Branch Linux Swift 4.1 Compatible Swift 4.1 Compatible Join the Smoke Server Side community on gitter Apache 2

SmokeHTTP

SmokeHTTP contains the library SmokeHTTPClient which will allow someone building a specific client that requires unique use-cases for HTTP parameters to utilize a generic HTTPClient that allows the user to implement their own delegates that handles client-specific HTTP logic.

The benefit of this package is to consolidate all HTTPClient logic into one location, while other clients are built to utilize this client while defining their own specific delegates.

SmokeHTTPClient

To use SmokeHTTPClient, a user can instantiate an HTTPClient in the constructor of their specific client with instantiated delegates (HTTPClientDelegate, HTTPClientChannelInboundHandlerDelegate) that are defined by the client-specific logic.

Getting Started

Step 1: Add the SmokeHTTP dependency

SmokeHTTP uses the Swift Package Manager. To use the framework, add the following dependency to your Package.swift-

dependencies: [
    .package(url: "https://github.com/amzn/smoke-http.git", from: "1.0.0")
]

.target(
    name: ...,
    dependencies: [..., "SmokeHTTPClient"]),

Step 2: Construct a HTTPClient

Construct a HTTPClient using the following code-

import SmokeHTTPClient

let httpClient = HTTPClient(endpointHostName: endpointHostName,
                            endpointPort: endpointPort,
                            contentType: contentType,
                            clientDelegate: clientDelegate,
                            connectionTimeoutSeconds: connectionTimeoutSeconds)

where clientDelegate conforms to the HTTPClientDelegate protocol.

License

This library is licensed under the Apache 2.0 License.

About

Generic HTTP client for Swift applications

License:Apache License 2.0


Languages

Language:Swift 99.9%Language:Shell 0.1%