{"action":"opened","number":28,"pull_request":{"url":"https://api.github.com/repos/koajs/route/pulls/28","id":39286950,"html_url":"https://github.com/koajs/route/pull/28","diff_url":"https://github.com/koajs/route/pull/28.diff","patch_url":"https://github.com/koajs/route/pull/28.patch","issue_url":"https://api.github.com/repos/koajs/route/issues/28","number":28,"state":"open","locked":false,"title":"Add support for prefixing","user":{"login":"PaulAvery","id":5328822,"avatar_url":"https://avatars.githubusercontent.com/u/5328822?v=3","gravatar_id":"","url":"https://api.github.com/users/PaulAvery","html_url":"https://github.com/PaulAvery","followers_url":"https://api.github.com/users/PaulAvery/followers","following_url":"https://api.github.com/users/PaulAvery/following{/other_user}","gists_url":"https://api.github.com/users/PaulAvery/gists{/gist_id}","starred_url":"https://api.github.com/users/PaulAvery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaulAvery/subscriptions","organizations_url":"https://api.github.com/users/PaulAvery/orgs","repos_url":"https://api.github.com/users/PaulAvery/repos","events_url":"https://api.github.com/users/PaulAvery/events{/privacy}","received_events_url":"https://api.github.com/users/PaulAvery/received_events","type":"User","site_admin":false},"body":"Hi, so today I realised, that I would love to define prefixes for sets of routes.\r\nThis PR therefore allows for the following:\r\n\r\n```js\r\nvar _ = require('koa-route');\r\n// Lets create a prefix\r\nvar api = _('/api');\r\n\r\n// We can nest prefixes if we want to\r\nvar v1 = api('/v1');\r\n\r\n// Or define them directly\r\nvar v2 = api('/api/v2');\r\n\r\n// /api/v1/some/route\r\nkoa.use(v1.get('/some/route', route));\r\n\r\n// /api/v1/some/:parameterized/route\r\nkoa.use(v1.get('/some/:parameterized/route', route));\r\n\r\n// /api/v2\r\nkoa.use(v2.all(route));\r\n\r\n// /api/v2/\r\nkoa.use(v2.all('/', route));\r\n\r\n// This still works\r\nkoa.use(_.get('/some/view', view));\r\n```\r\n\r\nI hope this change does not increase the scope of this module too much for your taste.\r\nI changed the readme and example.js as well as the tests, to acommondate the new feature.\r\nI am not sure about the way I restructured the tests though, I just ran all of them twice, once with a prefix and one without.\r\n\r\nPlease let me know if you like the idea, and if neccessary, which changes would need to be made to land this PR.","created_at":"2015-07-06T16:42:39Z","updated_at":"2015-07-06T16:42:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7a6896629f1f30ebaf16a1eddccfac91cc181f9a","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/koajs/route/pulls/28/commits","review_comments_url":"https://api.github.com/repos/koajs/route/pulls/28/comments","review_comment_url":"https://api.github.com/repos/koajs/route/pulls/comments{/number}","comments_url":"https://api.github.com/repos/koajs/route/issues/28/comments","statuses_url":"https://api.github.com/repos/koajs/route/statuses/264c33498a43641fd00e899cfa30a60576aae2fc","head":{"label":"PaulAvery:master","ref":"master","sha":"264c33498a43641fd00e899cfa30a60576aae2fc","user":{"login":"PaulAvery","id":5328822,"avatar_url":"https://avatars.githubusercontent.com/u/5328822?v=3","gravatar_id":"","url":"https://api.github.com/users/PaulAvery","html_url":"https://github.com/PaulAvery","followers_url":"https://api.github.com/users/PaulAvery/followers","following_url":"https://api.github.com/users/PaulAvery/following{/other_user}","gists_url":"https://api.github.com/users/PaulAvery/gists{/gist_id}","starred_url":"https://api.github.com/users/PaulAvery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaulAvery/subscriptions","organizations_url":"https://api.github.com/users/PaulAvery/orgs","repos_url":"https://api.github.com/users/PaulAvery/repos","events_url":"https://api.github.com/users/PaulAvery/events{/privacy}","received_events_url":"https://api.github.com/users/PaulAvery/received_events","type":"User","site_admin":false},"repo":{"id":38630759,"name":"route","full_name":"PaulAvery/route","owner":{"login":"PaulAvery","id":5328822,"avatar_url":"https://avatars.githubusercontent.com/u/5328822?v=3","gravatar_id":"","url":"https://api.github.com/users/PaulAvery","html_url":"https://github.com/PaulAvery","followers_url":"https://api.github.com/users/PaulAvery/followers","following_url":"https://api.github.com/users/PaulAvery/following{/other_user}","gists_url":"https://api.github.com/users/PaulAvery/gists{/gist_id}","starred_url":"https://api.github.com/users/PaulAvery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PaulAvery/subscriptions","organizations_url":"https://api.github.com/users/PaulAvery/orgs","repos_url":"https://api.github.com/users/PaulAvery/repos","events_url":"https://api.github.com/users/PaulAvery/events{/privacy}","received_events_url":"https://api.github.com/users/PaulAvery/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/PaulAvery/route","description":"Simple route middleware","fork":true,"url":"https://api.github.com/repos/PaulAvery/route","forks_url":"https://api.github.com/repos/PaulAvery/route/forks","keys_url":"https://api.github.com/repos/PaulAvery/route/keys{/key_id}","collaborators_url":"https://api.github.com/repos/PaulAvery/route/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/PaulAvery/route/teams","hooks_url":"https://api.github.com/repos/PaulAvery/route/hooks","issue_events_url":"https://api.github.com/repos/PaulAvery/route/issues/events{/number}","events_url":"https://api.github.com/repos/PaulAvery/route/events","assignees_url":"https://api.github.com/repos/PaulAvery/route/assignees{/user}","branches_url":"https://api.github.com/repos/PaulAvery/route/branches{/branch}","tags_url":"https://api.github.com/repos/PaulAvery/route/tags","blobs_url":"https://api.github.com/repos/PaulAvery/route/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/PaulAvery/route/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/PaulAvery/route/git/refs{/sha}","trees_url":"https://api.github.com/repos/PaulAvery/route/git/trees{/sha}","statuses_url":"https://api.github.com/repos/PaulAvery/route/statuses/{sha}","languages_url":"https://api.github.com/repos/PaulAvery/route/languages","stargazers_url":"https://api.github.com/repos/PaulAvery/route/stargazers","contributors_url":"https://api.github.com/repos/PaulAvery/route/contributors","subscribers_url":"https://api.github.com/repos/PaulAvery/route/subscribers","subscription_url":"https://api.github.com/repos/PaulAvery/route/subscription","commits_url":"https://api.github.com/repos/PaulAvery/route/commits{/sha}","git_commits_url":"https://api.github.com/repos/PaulAvery/route/git/commits{/sha}","comments_url":"https://api.github.com/repos/PaulAvery/route/comments{/number}","issue_comment_url":"https://api.github.com/repos/PaulAvery/route/issues/comments{/number}","contents_url":"https://api.github.com/repos/PaulAvery/route/contents/{+path}","compare_url":"https://api.github.com/repos/PaulAvery/route/compare/{base}...{head}","merges_url":"https://api.github.com/repos/PaulAvery/route/merges","archive_url":"https://api.github.com/repos/PaulAvery/route/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/PaulAvery/route/downloads","issues_url":"https://api.github.com/repos/PaulAvery/route/issues{/number}","pulls_url":"https://api.github.com/repos/PaulAvery/route/pulls{/number}","milestones_url":"https://api.github.com/repos/PaulAvery/route/milestones{/number}","notifications_url":"https://api.github.com/repos/PaulAvery/route/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/PaulAvery/route/labels{/name}","releases_url":"https://api.github.com/repos/PaulAvery/route/releases{/id}","created_at":"2015-07-06T16:15:59Z","updated_at":"2015-07-06T16:16:00Z","pushed_at":"2015-07-06T16:29:04Z","git_url":"git://github.com/PaulAvery/route.git","ssh_url":"git@github.com:PaulAvery/route.git","clone_url":"https://github.com/PaulAvery/route.git","svn_url":"https://github.com/PaulAvery/route","homepage":null,"size":345,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"koajs:master","ref":"master","sha":"b17cd9d8d9a93c5ff4addb015efc4d28a27121b2","user":{"login":"koajs","id":5055057,"avatar_url":"https://avatars.githubusercontent.com/u/5055057?v=3","gravatar_id":"","url":"https://api.github.com/users/koajs","html_url":"https://github.com/koajs","followers_url":"https://api.github.com/users/koajs/followers","following_url":"https://api.github.com/users/koajs/following{/other_user}","gists_url":"https://api.github.com/users/koajs/gists{/gist_id}","starred_url":"https://api.github.com/users/koajs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koajs/subscriptions","organizations_url":"https://api.github.com/users/koajs/orgs","repos_url":"https://api.github.com/users/koajs/repos","events_url":"https://api.github.com/users/koajs/events{/privacy}","received_events_url":"https://api.github.com/users/koajs/received_events","type":"Organization","site_admin":false},"repo":{"id":14185551,"name":"route","full_name":"koajs/route","owner":{"login":"koajs","id":5055057,"avatar_url":"https://avatars.githubusercontent.com/u/5055057?v=3","gravatar_id":"","url":"https://api.github.com/users/koajs","html_url":"https://github.com/koajs","followers_url":"https://api.github.com/users/koajs/followers","following_url":"https://api.github.com/users/koajs/following{/other_user}","gists_url":"https://api.github.com/users/koajs/gists{/gist_id}","starred_url":"https://api.github.com/users/koajs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/koajs/subscriptions","organizations_url":"https://api.github.com/users/koajs/orgs","repos_url":"https://api.github.com/users/koajs/repos","events_url":"https://api.github.com/users/koajs/events{/privacy}","received_events_url":"https://api.github.com/users/koajs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/koajs/route","description":"Simple route middleware","fork":false,"url":"https://api.github.com/repos/koajs/route","forks_url":"https://api.github.com/repos/koajs/route/forks","keys_url":"https://api.github.com/repos/koajs/route/keys{/key_id}","collaborators_url":"https://api.github.com/repos/koajs/route/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/koajs/route/teams","hooks_url":"https://api.github.com/repos/koajs/route/hooks","issue_events_url":"https://api.github.com/repos/koajs/route/issues/events{/number}","events_url":"https://api.github.com/repos/koajs/route/events","assignees_url":"https://api.github.com/repos/koajs/route/assignees{/user}","branches_url":"https://api.github.com/repos/koajs/route/branches{/branch}","tags_url":"https://api.github.com/repos/koajs/route/tags","blobs_url":"https://api.github.com/repos/koajs/route/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/koajs/route/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/koajs/route/git/refs{/sha}","trees_url":"https://api.github.com/repos/koajs/route/git/trees{/sha}","statuses_url":"https://api.github.com/repos/koajs/route/statuses/{sha}","languages_url":"https://api.github.com/repos/koajs/route/languages","stargazers_url":"https://api.github.com/repos/koajs/route/stargazers","contributors_url":"https://api.github.com/repos/koajs/route/contributors","subscribers_url":"https://api.github.com/repos/koajs/route/subscribers","subscription_url":"https://api.github.com/repos/koajs/route/subscription","commits_url":"https://api.github.com/repos/koajs/route/commits{/sha}","git_commits_url":"https://api.github.com/repos/koajs/route/git/commits{/sha}","comments_url":"https://api.github.com/repos/koajs/route/comments{/number}","issue_comment_url":"https://api.github.com/repos/koajs/route/issues/comments{/number}","contents_url":"https://api.github.com/repos/koajs/route/contents/{+path}","compare_url":"https://api.github.com/repos/koajs/route/compare/{base}...{head}","merges_url":"https://api.github.com/repos/koajs/route/merges","archive_url":"https://api.github.com/repos/koajs/route/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/koajs/route/downloads","issues_url":"https://api.github.com/repos/koajs/route/issues{/number}","pulls_url":"https://api.github.com/repos/koajs/route/pulls{/number}","milestones_url":"https://api.github.com/repos/koajs/route/milestones{/number}","notifications_url":"https://api.github.com/repos/koajs/route/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/koajs/route/labels{/name}","releases_url":"https://api.github.com/repos/koajs/route/releases{/id}","created_at":"2013-11-06T21:04:46Z","updated_at":"2015-06-30T19:59:36Z","pushed_at":"2015-07-06T16:42:39Z","git_url":"git://github.com/koajs/route.git","ssh_url":"git@github.com:koajs/route.git","clone_url":"https://github.com/koajs/route.git","svn_url":"https://github.com/koajs/route","homepage":null,"size":345,"stargazers_count":103,"watchers_count":103,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":2,"forks":19,"open_issues":2,"watchers":103,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/koajs/route/pulls/28"},"html":{"href":"https://github.com/koajs/route/pull/28"},"issue":{"href":"https://api.github.com/repos/koajs/route/issues/28"},"comments":{"href":"https://api.github.com/repos/koajs/route/issues/28/comments"},"review_comments":{"href":"https://api.github.com/repos/koajs/route/pulls/28/comments"},"review_comment":{"href":"https://api.github.com/repos/koajs/route/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/koajs/route/pulls/28/commits"},"statuses":{"href":"https://api.github.com/repos/koajs/route/statuses/264c33498a43641fd00e899cfa30a60576aae2fc"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":158,"deletions":118,"changed_files":4}}