Skip to content

Instantly share code, notes, and snippets.

@koromiko
Last active August 10, 2017 16:33
Show Gist options
  • Save koromiko/c29de5e895ec20620e9c0a402ccf45f6 to your computer and use it in GitHub Desktop.
Save koromiko/c29de5e895ec20620e9c0a402ccf45f6 to your computer and use it in GitHub Desktop.
class HttpClient {
typealias completeClosure = ( _ data: Data?, _ error: Error?)->Void
func get( url: URL, callback: @escaping completeClosure ) {
let request = NSMutableURLRequest(url: url)
request.httpMethod = "GET"
let task = URLSession.shared.dataTask(with: request) { (data, response, error) in
callback(data, error)
}
task.resume()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment