Skip to content

Instantly share code, notes, and snippets.

@hirokazumiyaji
Created September 28, 2015 14:42
Show Gist options
  • Save hirokazumiyaji/5776ee729e7e037cb030 to your computer and use it in GitHub Desktop.
Save hirokazumiyaji/5776ee729e7e037cb030 to your computer and use it in GitHub Desktop.
import Foundation
public class GithubAPI {
public init() {
}
public func request<Endpoint: APIEndpoint>(endpoint: Endpoint, handler: (data, response, error) -> Void) {
let url = NSURL(string: "https://api.github.com/search/repositories?q=Hatena&page=1")!
let request = NSMutableURLRequest(URL: url)
request.SetValue("application/vnd.github.v3+json", forHTTPHeaderField: "Accept")
let session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration())
session.dataTaskWithRequest(request, completionHandler: handler).resume()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment