Skip to content

Instantly share code, notes, and snippets.

@vsouza

vsouza/request.swift

Last active May 31, 2016
Embed
What would you like to do?
Simple HTTP request. Swift backend implementation
import HTTP
import File
import HTTPSClient
import JSON
var url: String?
do {
let client = try! Client(uri: "https://api.github.com:443")
var response = try client.get("/repos/vsouza/awesome-ios/git/trees/HEAD")
let buffer = try response.body.becomeBuffer()
let parsed = try! JSONParser().parse(data: buffer)
print(parsed)
} catch {
print("Response error")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment