Skip to content

Instantly share code, notes, and snippets.

@vsouza
Last active May 31, 2016 13:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsouza/4d7bfa47864f2be07a3272bcacd28542 to your computer and use it in GitHub Desktop.
Save vsouza/4d7bfa47864f2be07a3272bcacd28542 to your computer and use it in GitHub Desktop.
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