GitXplorerGitXplorer
t

AsyncHTTP

public
13 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
216463f301761c8510a9d2cb9088ea2b85bab63d

Refactor multipart

ttevelee committed 2 years ago
Unverified
5634ade87043072ee7a76802a01235ae240cfc4c

Bugfix: default server environment

ttevelee committed 2 years ago
Unverified
f800840ee803d11d379203611a8ba68caf57418f

NetworkConstrained Loader

ttevelee committed 2 years ago
Unverified
37890727595168a08618fbc56d1e07c295ce9e1f

Clock, retry strategy

ttevelee committed 2 years ago
Unverified
56228ff141d61083071bd941db2918a4dc040143

Adopting primary associated types

ttevelee committed 2 years ago
Unverified
1fab6701071573feaf960b02745344b6f4e4ac0c

Using swift tools v5.5

ttevelee committed 3 years ago

README

The README file for this repository.

AsyncHTTP

Generic networking library written using Swift async/await

let request = try HTTPRequest().configured { request in
    request.path = "endpoint"
    request.method = .post
    request.body = try .json(["a": "b"])
    request[header: .accept] = .application.json.appending(.characterSet, value: .utf8)
    request[header: .authorization] = .bearer(token: "token")
    request.addQueryParameter(name: "q", value: "search")
    request.serverEnvironment = .production
    request.timeout = 60
    request.retryStrategy = .immediately(maximumNumberOfAttempts: 3)
}

let loader: some HTTPLoader = URLSession.shared.httpLoader()
    .applyServerEnvironment()
    .applyTimeout(default: 30)
    .applyRetryStrategy()
    .deduplicate()
    .throttle(maximumNumberOfRequests: 2)

let response: HTTPResponse = try await loader.load(request)
let body: MyResponseStruct = try response.jsonBody()

print(request.formatted())
print(response.formatted())