Created
September 28, 2015 14:42
-
-
Save hirokazumiyaji/5776ee729e7e037cb030 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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