{"action":"created","comment":{"url":"https://api.github.com/repos/devlucky/Kakapo/pulls/comments/61416831","id":61416831,"diff_hunk":"@@ -33,61 +33,54 @@ public struct Response: CustomSerializable {\n     }\n }\n \n-public class KakapoServer: NSURLProtocol {\n-\n-    private typealias Route = (method: HTTPMethod, handler: RouteHandler)\n+public class Router {\n     \n     private enum HTTPMethod: String {\n         case GET, POST, PUT, DELETE\n     }\n+    private typealias Route = (method: HTTPMethod, handler: RouteHandler)\n     \n-    private static var routes: [String : Route] = [:]\n+    private var routes: [String : Route] = [:]\n+    public let baseURL: String\n     \n-    public class func enable() {\n-        NSURLProtocol.registerClass(self)\n+    init(baseURL: String) {\n+        self.baseURL = baseURL\n     }\n     \n-    public class func disable() {\n-        routes = [:]\n-        NSURLProtocol.unregisterClass(self)\n-    }\n-    \n-    override public class func canInitWithRequest(request: NSURLRequest) -> Bool {\n-        guard let requestString = request.URL?.absoluteString else { return false }\n+    func canInitWithRequest(request: NSURLRequest) -> Bool {\n+        guard let requestURL = request.URL,\n+                  components = requestURL.componentsFromBaseURL(baseURL) else { return false }","path":"Source/KakapoServer.swift","position":51,"original_position":51,"commit_id":"63274869b635ea989e0fd8c62ad2f015629fc349","original_commit_id":"63274869b635ea989e0fd8c62ad2f015629fc349","user":{"login":"MP0w","id":1812932,"avatar_url":"https://avatars.githubusercontent.com/u/1812932?v=3","gravatar_id":"","url":"https://api.github.com/users/MP0w","html_url":"https://github.com/MP0w","followers_url":"https://api.github.com/users/MP0w/followers","following_url":"https://api.github.com/users/MP0w/following{/other_user}","gists_url":"https://api.github.com/users/MP0w/gists{/gist_id}","starred_url":"https://api.github.com/users/MP0w/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MP0w/subscriptions","organizations_url":"https://api.github.com/users/MP0w/orgs","repos_url":"https://api.github.com/users/MP0w/repos","events_url":"https://api.github.com/users/MP0w/events{/privacy}","received_events_url":"https://api.github.com/users/MP0w/received_events","type":"User","site_admin":false},"body":"why is this needed?","created_at":"2016-04-28T12:14:49Z","updated_at":"2016-04-28T12:14:49Z","html_url":"https://github.com/devlucky/Kakapo/pull/49#discussion_r61416831","pull_request_url":"https://api.github.com/repos/devlucky/Kakapo/pulls/49","_links":{"self":{"href":"https://api.github.com/repos/devlucky/Kakapo/pulls/comments/61416831"},"html":{"href":"https://github.com/devlucky/Kakapo/pull/49#discussion_r61416831"},"pull_request":{"href":"https://api.github.com/repos/devlucky/Kakapo/pulls/49"}}},"pull_request":{"url":"https://api.github.com/repos/devlucky/Kakapo/pulls/49","id":67963444,"html_url":"https://github.com/devlucky/Kakapo/pull/49","diff_url":"https://github.com/devlucky/Kakapo/pull/49.diff","patch_url":"https://github.com/devlucky/Kakapo/pull/49.patch","issue_url":"https://api.github.com/repos/devlucky/Kakapo/issues/49","number":49,"state":"open","locked":false,"title":"Feature/host request","user":{"login":"joanromano","id":1227808,"avatar_url":"https://avatars.githubusercontent.com/u/1227808?v=3","gravatar_id":"","url":"https://api.github.com/users/joanromano","html_url":"https://github.com/joanromano","followers_url":"https://api.github.com/users/joanromano/followers","following_url":"https://api.github.com/users/joanromano/following{/other_user}","gists_url":"https://api.github.com/users/joanromano/gists{/gist_id}","starred_url":"https://api.github.com/users/joanromano/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joanromano/subscriptions","organizations_url":"https://api.github.com/users/joanromano/orgs","repos_url":"https://api.github.com/users/joanromano/repos","events_url":"https://api.github.com/users/joanromano/events{/privacy}","received_events_url":"https://api.github.com/users/joanromano/received_events","type":"User","site_admin":false},"body":"Closes #23 and #24 \r\n\r\nTo discuss:\r\n\r\n- [ ] Whether new `decomposeURL` is flexible enough\r\n- [x] Whether registration of routers with scheme (e.g `http`) should fail afterwards and so registration should always be without it, only host (`www.foo.com`) -> See tests for more info\r\n- [ ] Whether we want to unregister by host string instead of handling the router instance in the unregister method of `KakapoServer` (currently by host string) -> See tests for more info","created_at":"2016-04-26T21:44:12Z","updated_at":"2016-04-28T12:14:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4f3d9473200e2b35c0d8a97a04ae9bb9025efe11","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/devlucky/Kakapo/pulls/49/commits","review_comments_url":"https://api.github.com/repos/devlucky/Kakapo/pulls/49/comments","review_comment_url":"https://api.github.com/repos/devlucky/Kakapo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/devlucky/Kakapo/issues/49/comments","statuses_url":"https://api.github.com/repos/devlucky/Kakapo/statuses/63274869b635ea989e0fd8c62ad2f015629fc349","head":{"label":"devlucky:feature/hostRequest","ref":"feature/hostRequest","sha":"63274869b635ea989e0fd8c62ad2f015629fc349","user":{"login":"devlucky","id":18127620,"avatar_url":"https://avatars.githubusercontent.com/u/18127620?v=3","gravatar_id":"","url":"https://api.github.com/users/devlucky","html_url":"https://github.com/devlucky","followers_url":"https://api.github.com/users/devlucky/followers","following_url":"https://api.github.com/users/devlucky/following{/other_user}","gists_url":"https://api.github.com/users/devlucky/gists{/gist_id}","starred_url":"https://api.github.com/users/devlucky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devlucky/subscriptions","organizations_url":"https://api.github.com/users/devlucky/orgs","repos_url":"https://api.github.com/users/devlucky/repos","events_url":"https://api.github.com/users/devlucky/events{/privacy}","received_events_url":"https://api.github.com/users/devlucky/received_events","type":"Organization","site_admin":false},"repo":{"id":54993813,"name":"Kakapo","full_name":"devlucky/Kakapo","owner":{"login":"devlucky","id":18127620,"avatar_url":"https://avatars.githubusercontent.com/u/18127620?v=3","gravatar_id":"","url":"https://api.github.com/users/devlucky","html_url":"https://github.com/devlucky","followers_url":"https://api.github.com/users/devlucky/followers","following_url":"https://api.github.com/users/devlucky/following{/other_user}","gists_url":"https://api.github.com/users/devlucky/gists{/gist_id}","starred_url":"https://api.github.com/users/devlucky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devlucky/subscriptions","organizations_url":"https://api.github.com/users/devlucky/orgs","repos_url":"https://api.github.com/users/devlucky/repos","events_url":"https://api.github.com/users/devlucky/events{/privacy}","received_events_url":"https://api.github.com/users/devlucky/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/devlucky/Kakapo","description":":bird: Next generation network mocking library in Swift","fork":false,"url":"https://api.github.com/repos/devlucky/Kakapo","forks_url":"https://api.github.com/repos/devlucky/Kakapo/forks","keys_url":"https://api.github.com/repos/devlucky/Kakapo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/devlucky/Kakapo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/devlucky/Kakapo/teams","hooks_url":"https://api.github.com/repos/devlucky/Kakapo/hooks","issue_events_url":"https://api.github.com/repos/devlucky/Kakapo/issues/events{/number}","events_url":"https://api.github.com/repos/devlucky/Kakapo/events","assignees_url":"https://api.github.com/repos/devlucky/Kakapo/assignees{/user}","branches_url":"https://api.github.com/repos/devlucky/Kakapo/branches{/branch}","tags_url":"https://api.github.com/repos/devlucky/Kakapo/tags","blobs_url":"https://api.github.com/repos/devlucky/Kakapo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/devlucky/Kakapo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/devlucky/Kakapo/git/refs{/sha}","trees_url":"https://api.github.com/repos/devlucky/Kakapo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/devlucky/Kakapo/statuses/{sha}","languages_url":"https://api.github.com/repos/devlucky/Kakapo/languages","stargazers_url":"https://api.github.com/repos/devlucky/Kakapo/stargazers","contributors_url":"https://api.github.com/repos/devlucky/Kakapo/contributors","subscribers_url":"https://api.github.com/repos/devlucky/Kakapo/subscribers","subscription_url":"https://api.github.com/repos/devlucky/Kakapo/subscription","commits_url":"https://api.github.com/repos/devlucky/Kakapo/commits{/sha}","git_commits_url":"https://api.github.com/repos/devlucky/Kakapo/git/commits{/sha}","comments_url":"https://api.github.com/repos/devlucky/Kakapo/comments{/number}","issue_comment_url":"https://api.github.com/repos/devlucky/Kakapo/issues/comments{/number}","contents_url":"https://api.github.com/repos/devlucky/Kakapo/contents/{+path}","compare_url":"https://api.github.com/repos/devlucky/Kakapo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/devlucky/Kakapo/merges","archive_url":"https://api.github.com/repos/devlucky/Kakapo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/devlucky/Kakapo/downloads","issues_url":"https://api.github.com/repos/devlucky/Kakapo/issues{/number}","pulls_url":"https://api.github.com/repos/devlucky/Kakapo/pulls{/number}","milestones_url":"https://api.github.com/repos/devlucky/Kakapo/milestones{/number}","notifications_url":"https://api.github.com/repos/devlucky/Kakapo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/devlucky/Kakapo/labels{/name}","releases_url":"https://api.github.com/repos/devlucky/Kakapo/releases{/id}","deployments_url":"https://api.github.com/repos/devlucky/Kakapo/deployments","created_at":"2016-03-29T16:57:21Z","updated_at":"2016-04-26T15:38:01Z","pushed_at":"2016-04-28T11:44:07Z","git_url":"git://github.com/devlucky/Kakapo.git","ssh_url":"git@github.com:devlucky/Kakapo.git","clone_url":"https://github.com/devlucky/Kakapo.git","svn_url":"https://github.com/devlucky/Kakapo","homepage":"","size":572,"stargazers_count":9,"watchers_count":9,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":17,"forks":0,"open_issues":17,"watchers":9,"default_branch":"master"}},"base":{"label":"devlucky:master","ref":"master","sha":"3547a12bea5bfac6570afe234abfb14e1f7b86b6","user":{"login":"devlucky","id":18127620,"avatar_url":"https://avatars.githubusercontent.com/u/18127620?v=3","gravatar_id":"","url":"https://api.github.com/users/devlucky","html_url":"https://github.com/devlucky","followers_url":"https://api.github.com/users/devlucky/followers","following_url":"https://api.github.com/users/devlucky/following{/other_user}","gists_url":"https://api.github.com/users/devlucky/gists{/gist_id}","starred_url":"https://api.github.com/users/devlucky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devlucky/subscriptions","organizations_url":"https://api.github.com/users/devlucky/orgs","repos_url":"https://api.github.com/users/devlucky/repos","events_url":"https://api.github.com/users/devlucky/events{/privacy}","received_events_url":"https://api.github.com/users/devlucky/received_events","type":"Organization","site_admin":false},"repo":{"id":54993813,"name":"Kakapo","full_name":"devlucky/Kakapo","owner":{"login":"devlucky","id":18127620,"avatar_url":"https://avatars.githubusercontent.com/u/18127620?v=3","gravatar_id":"","url":"https://api.github.com/users/devlucky","html_url":"https://github.com/devlucky","followers_url":"https://api.github.com/users/devlucky/followers","following_url":"https://api.github.com/users/devlucky/following{/other_user}","gists_url":"https://api.github.com/users/devlucky/gists{/gist_id}","starred_url":"https://api.github.com/users/devlucky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devlucky/subscriptions","organizations_url":"https://api.github.com/users/devlucky/orgs","repos_url":"https://api.github.com/users/devlucky/repos","events_url":"https://api.github.com/users/devlucky/events{/privacy}","received_events_url":"https://api.github.com/users/devlucky/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/devlucky/Kakapo","description":":bird: Next generation network mocking library in Swift","fork":false,"url":"https://api.github.com/repos/devlucky/Kakapo","forks_url":"https://api.github.com/repos/devlucky/Kakapo/forks","keys_url":"https://api.github.com/repos/devlucky/Kakapo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/devlucky/Kakapo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/devlucky/Kakapo/teams","hooks_url":"https://api.github.com/repos/devlucky/Kakapo/hooks","issue_events_url":"https://api.github.com/repos/devlucky/Kakapo/issues/events{/number}","events_url":"https://api.github.com/repos/devlucky/Kakapo/events","assignees_url":"https://api.github.com/repos/devlucky/Kakapo/assignees{/user}","branches_url":"https://api.github.com/repos/devlucky/Kakapo/branches{/branch}","tags_url":"https://api.github.com/repos/devlucky/Kakapo/tags","blobs_url":"https://api.github.com/repos/devlucky/Kakapo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/devlucky/Kakapo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/devlucky/Kakapo/git/refs{/sha}","trees_url":"https://api.github.com/repos/devlucky/Kakapo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/devlucky/Kakapo/statuses/{sha}","languages_url":"https://api.github.com/repos/devlucky/Kakapo/languages","stargazers_url":"https://api.github.com/repos/devlucky/Kakapo/stargazers","contributors_url":"https://api.github.com/repos/devlucky/Kakapo/contributors","subscribers_url":"https://api.github.com/repos/devlucky/Kakapo/subscribers","subscription_url":"https://api.github.com/repos/devlucky/Kakapo/subscription","commits_url":"https://api.github.com/repos/devlucky/Kakapo/commits{/sha}","git_commits_url":"https://api.github.com/repos/devlucky/Kakapo/git/commits{/sha}","comments_url":"https://api.github.com/repos/devlucky/Kakapo/comments{/number}","issue_comment_url":"https://api.github.com/repos/devlucky/Kakapo/issues/comments{/number}","contents_url":"https://api.github.com/repos/devlucky/Kakapo/contents/{+path}","compare_url":"https://api.github.com/repos/devlucky/Kakapo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/devlucky/Kakapo/merges","archive_url":"https://api.github.com/repos/devlucky/Kakapo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/devlucky/Kakapo/downloads","issues_url":"https://api.github.com/repos/devlucky/Kakapo/issues{/number}","pulls_url":"https://api.github.com/repos/devlucky/Kakapo/pulls{/number}","milestones_url":"https://api.github.com/repos/devlucky/Kakapo/milestones{/number}","notifications_url":"https://api.github.com/repos/devlucky/Kakapo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/devlucky/Kakapo/labels{/name}","releases_url":"https://api.github.com/repos/devlucky/Kakapo/releases{/id}","deployments_url":"https://api.github.com/repos/devlucky/Kakapo/deployments","created_at":"2016-03-29T16:57:21Z","updated_at":"2016-04-26T15:38:01Z","pushed_at":"2016-04-28T11:44:07Z","git_url":"git://github.com/devlucky/Kakapo.git","ssh_url":"git@github.com:devlucky/Kakapo.git","clone_url":"https://github.com/devlucky/Kakapo.git","svn_url":"https://github.com/devlucky/Kakapo","homepage":"","size":572,"stargazers_count":9,"watchers_count":9,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":17,"forks":0,"open_issues":17,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/devlucky/Kakapo/pulls/49"},"html":{"href":"https://github.com/devlucky/Kakapo/pull/49"},"issue":{"href":"https://api.github.com/repos/devlucky/Kakapo/issues/49"},"comments":{"href":"https://api.github.com/repos/devlucky/Kakapo/issues/49/comments"},"review_comments":{"href":"https://api.github.com/repos/devlucky/Kakapo/pulls/49/comments"},"review_comment":{"href":"https://api.github.com/repos/devlucky/Kakapo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/devlucky/Kakapo/pulls/49/commits"},"statuses":{"href":"https://api.github.com/repos/devlucky/Kakapo/statuses/63274869b635ea989e0fd8c62ad2f015629fc349"}}}}