https://github.com/oleander/hub-swift
A client-side HTTP library
https://github.com/oleander/hub-swift
Last synced: 12 months ago
JSON representation
A client-side HTTP library
- Host: GitHub
- URL: https://github.com/oleander/hub-swift
- Owner: oleander
- Created: 2018-09-17T10:18:51.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-07-03T04:31:46.000Z (about 7 years ago)
- Last Synced: 2025-01-21T14:47:43.991Z (over 1 year ago)
- Language: Swift
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Hub
Hub is a client-side HTTP library written in Swift
## Example
``` swift
import Hub
let session = Hub(
host: URL("https://api.example.com"),
headers: [
"Accept": "application/json",
"Content-Type": "application/json; charset=utf-8",
"Cache-Control": "max-age=0"
],
cachePolicy: .returnCacheDataElseLoad,
logLevel: .info
)
print(try session.get(path: "/hello").json())
```
``` swift
let html = try Hub.post(
url: "http://example.com",
params: [
"param1": "value1"
],
files: [],
headers: [],
cookies: [],
logLevel: .info
).html()
```
## Install
``` swift
// swift-tools-version: 4.2
import PackageDescription
let package = Package(
name: "YOUR_PROJECT_NAME",
dependencies: [
.package(url: "https://github.com/oleander/hub-swift.git", .branch("master")),
]
)
```