{"action":"closed","number":115,"pull_request":{"url":"https://api.github.com/repos/thephpleague/route/pulls/115","id":65148390,"html_url":"https://github.com/thephpleague/route/pull/115","diff_url":"https://github.com/thephpleague/route/pull/115.diff","patch_url":"https://github.com/thephpleague/route/pull/115.patch","issue_url":"https://api.github.com/repos/thephpleague/route/issues/115","number":115,"state":"closed","locked":false,"title":"Middleware","user":{"login":"philipobenito","id":2077289,"avatar_url":"https://avatars.githubusercontent.com/u/2077289?v=3","gravatar_id":"","url":"https://api.github.com/users/philipobenito","html_url":"https://github.com/philipobenito","followers_url":"https://api.github.com/users/philipobenito/followers","following_url":"https://api.github.com/users/philipobenito/following{/other_user}","gists_url":"https://api.github.com/users/philipobenito/gists{/gist_id}","starred_url":"https://api.github.com/users/philipobenito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philipobenito/subscriptions","organizations_url":"https://api.github.com/users/philipobenito/orgs","repos_url":"https://api.github.com/users/philipobenito/repos","events_url":"https://api.github.com/users/philipobenito/events{/privacy}","received_events_url":"https://api.github.com/users/philipobenito/received_events","type":"User","site_admin":false},"body":"READ FURTHER DOWN THREAD FOR UPDATED FUNCTIONALITY\r\n\r\nAfter small discussion, closes #113 \r\n\r\nEnded up not bringing in an external middleware runner, really wasn't worth it.\r\n\r\nAs this PR stands\r\n\r\n- You can add middleware to the collection to run before or after any matched route. \r\n- You can add middleware to a route group that will only run when a route within that group is matched.\r\n- You can add middleware directly to a route meaning that it will only run if that route is matched.\r\n\r\n```php\r\n<?php\r\n\r\n$route = new League\\Route\\RouteCollection;\r\n\r\n$route->before(/* callable */);\r\n$route->after(/* callable */);\r\n\r\n$route\r\n    ->get('/something', function ($request, $response) {})\r\n    ->before(/* callable */)\r\n    ->after(/* callable */)\r\n;\r\n\r\n$route->group('/group', function ($route) {\r\n    $route->get('/', function ($request, $response) {})\r\n        ->before(/* callable */)\r\n        ->after(/* callable */)\r\n    ;\r\n})\r\n    ->before(/* callable */) \r\n    ->after(/* callable */)\r\n;\r\n```\r\n\r\nAs things stand, middleware will be invoked in the following order.\r\n\r\n1. Before middleware registered on the collection.\r\n2. Before middleware registered on the group.\r\n3. Before middleware registered on the route.\r\n4. The route callable.\r\n5. After middleware registered on the collection.\r\n6. After middleware registered on the group.\r\n7. After middleware registered on the route.\r\n\r\nI'd like some input on how we might swap 5 and 7 around whilst maintaining the order they were actually registered within that section.","created_at":"2016-04-04T13:53:04Z","updated_at":"2016-04-13T08:05:32Z","closed_at":"2016-04-13T08:05:32Z","merged_at":"2016-04-13T08:05:32Z","merge_commit_sha":"53f8191c27c6c77466d98d5ae4b118d735c10f9e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/thephpleague/route/pulls/115/commits","review_comments_url":"https://api.github.com/repos/thephpleague/route/pulls/115/comments","review_comment_url":"https://api.github.com/repos/thephpleague/route/pulls/comments{/number}","comments_url":"https://api.github.com/repos/thephpleague/route/issues/115/comments","statuses_url":"https://api.github.com/repos/thephpleague/route/statuses/53f8191c27c6c77466d98d5ae4b118d735c10f9e","head":{"label":"thephpleague:middleware","ref":"middleware","sha":"53f8191c27c6c77466d98d5ae4b118d735c10f9e","user":{"login":"thephpleague","id":527621,"avatar_url":"https://avatars.githubusercontent.com/u/527621?v=3","gravatar_id":"","url":"https://api.github.com/users/thephpleague","html_url":"https://github.com/thephpleague","followers_url":"https://api.github.com/users/thephpleague/followers","following_url":"https://api.github.com/users/thephpleague/following{/other_user}","gists_url":"https://api.github.com/users/thephpleague/gists{/gist_id}","starred_url":"https://api.github.com/users/thephpleague/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thephpleague/subscriptions","organizations_url":"https://api.github.com/users/thephpleague/orgs","repos_url":"https://api.github.com/users/thephpleague/repos","events_url":"https://api.github.com/users/thephpleague/events{/privacy}","received_events_url":"https://api.github.com/users/thephpleague/received_events","type":"Organization","site_admin":false},"repo":{"id":29130155,"name":"route","full_name":"thephpleague/route","owner":{"login":"thephpleague","id":527621,"avatar_url":"https://avatars.githubusercontent.com/u/527621?v=3","gravatar_id":"","url":"https://api.github.com/users/thephpleague","html_url":"https://github.com/thephpleague","followers_url":"https://api.github.com/users/thephpleague/followers","following_url":"https://api.github.com/users/thephpleague/following{/other_user}","gists_url":"https://api.github.com/users/thephpleague/gists{/gist_id}","starred_url":"https://api.github.com/users/thephpleague/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thephpleague/subscriptions","organizations_url":"https://api.github.com/users/thephpleague/orgs","repos_url":"https://api.github.com/users/thephpleague/repos","events_url":"https://api.github.com/users/thephpleague/events{/privacy}","received_events_url":"https://api.github.com/users/thephpleague/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thephpleague/route","description":"Fast router and dispatcher built on top of FastRoute","fork":false,"url":"https://api.github.com/repos/thephpleague/route","forks_url":"https://api.github.com/repos/thephpleague/route/forks","keys_url":"https://api.github.com/repos/thephpleague/route/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thephpleague/route/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thephpleague/route/teams","hooks_url":"https://api.github.com/repos/thephpleague/route/hooks","issue_events_url":"https://api.github.com/repos/thephpleague/route/issues/events{/number}","events_url":"https://api.github.com/repos/thephpleague/route/events","assignees_url":"https://api.github.com/repos/thephpleague/route/assignees{/user}","branches_url":"https://api.github.com/repos/thephpleague/route/branches{/branch}","tags_url":"https://api.github.com/repos/thephpleague/route/tags","blobs_url":"https://api.github.com/repos/thephpleague/route/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thephpleague/route/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thephpleague/route/git/refs{/sha}","trees_url":"https://api.github.com/repos/thephpleague/route/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thephpleague/route/statuses/{sha}","languages_url":"https://api.github.com/repos/thephpleague/route/languages","stargazers_url":"https://api.github.com/repos/thephpleague/route/stargazers","contributors_url":"https://api.github.com/repos/thephpleague/route/contributors","subscribers_url":"https://api.github.com/repos/thephpleague/route/subscribers","subscription_url":"https://api.github.com/repos/thephpleague/route/subscription","commits_url":"https://api.github.com/repos/thephpleague/route/commits{/sha}","git_commits_url":"https://api.github.com/repos/thephpleague/route/git/commits{/sha}","comments_url":"https://api.github.com/repos/thephpleague/route/comments{/number}","issue_comment_url":"https://api.github.com/repos/thephpleague/route/issues/comments{/number}","contents_url":"https://api.github.com/repos/thephpleague/route/contents/{+path}","compare_url":"https://api.github.com/repos/thephpleague/route/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thephpleague/route/merges","archive_url":"https://api.github.com/repos/thephpleague/route/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thephpleague/route/downloads","issues_url":"https://api.github.com/repos/thephpleague/route/issues{/number}","pulls_url":"https://api.github.com/repos/thephpleague/route/pulls{/number}","milestones_url":"https://api.github.com/repos/thephpleague/route/milestones{/number}","notifications_url":"https://api.github.com/repos/thephpleague/route/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thephpleague/route/labels{/name}","releases_url":"https://api.github.com/repos/thephpleague/route/releases{/id}","deployments_url":"https://api.github.com/repos/thephpleague/route/deployments","created_at":"2015-01-12T10:21:02Z","updated_at":"2016-04-12T06:35:26Z","pushed_at":"2016-04-13T08:05:32Z","git_url":"git://github.com/thephpleague/route.git","ssh_url":"git@github.com:thephpleague/route.git","clone_url":"https://github.com/thephpleague/route.git","svn_url":"https://github.com/thephpleague/route","homepage":"http://route.thephpleague.com","size":621,"stargazers_count":189,"watchers_count":189,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":38,"mirror_url":null,"open_issues_count":3,"forks":38,"open_issues":3,"watchers":189,"default_branch":"master"}},"base":{"label":"thephpleague:master","ref":"master","sha":"b818b076056ea2898ac24d5f8dd140fbc79b858d","user":{"login":"thephpleague","id":527621,"avatar_url":"https://avatars.githubusercontent.com/u/527621?v=3","gravatar_id":"","url":"https://api.github.com/users/thephpleague","html_url":"https://github.com/thephpleague","followers_url":"https://api.github.com/users/thephpleague/followers","following_url":"https://api.github.com/users/thephpleague/following{/other_user}","gists_url":"https://api.github.com/users/thephpleague/gists{/gist_id}","starred_url":"https://api.github.com/users/thephpleague/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thephpleague/subscriptions","organizations_url":"https://api.github.com/users/thephpleague/orgs","repos_url":"https://api.github.com/users/thephpleague/repos","events_url":"https://api.github.com/users/thephpleague/events{/privacy}","received_events_url":"https://api.github.com/users/thephpleague/received_events","type":"Organization","site_admin":false},"repo":{"id":29130155,"name":"route","full_name":"thephpleague/route","owner":{"login":"thephpleague","id":527621,"avatar_url":"https://avatars.githubusercontent.com/u/527621?v=3","gravatar_id":"","url":"https://api.github.com/users/thephpleague","html_url":"https://github.com/thephpleague","followers_url":"https://api.github.com/users/thephpleague/followers","following_url":"https://api.github.com/users/thephpleague/following{/other_user}","gists_url":"https://api.github.com/users/thephpleague/gists{/gist_id}","starred_url":"https://api.github.com/users/thephpleague/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thephpleague/subscriptions","organizations_url":"https://api.github.com/users/thephpleague/orgs","repos_url":"https://api.github.com/users/thephpleague/repos","events_url":"https://api.github.com/users/thephpleague/events{/privacy}","received_events_url":"https://api.github.com/users/thephpleague/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/thephpleague/route","description":"Fast router and dispatcher built on top of FastRoute","fork":false,"url":"https://api.github.com/repos/thephpleague/route","forks_url":"https://api.github.com/repos/thephpleague/route/forks","keys_url":"https://api.github.com/repos/thephpleague/route/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thephpleague/route/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thephpleague/route/teams","hooks_url":"https://api.github.com/repos/thephpleague/route/hooks","issue_events_url":"https://api.github.com/repos/thephpleague/route/issues/events{/number}","events_url":"https://api.github.com/repos/thephpleague/route/events","assignees_url":"https://api.github.com/repos/thephpleague/route/assignees{/user}","branches_url":"https://api.github.com/repos/thephpleague/route/branches{/branch}","tags_url":"https://api.github.com/repos/thephpleague/route/tags","blobs_url":"https://api.github.com/repos/thephpleague/route/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thephpleague/route/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thephpleague/route/git/refs{/sha}","trees_url":"https://api.github.com/repos/thephpleague/route/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thephpleague/route/statuses/{sha}","languages_url":"https://api.github.com/repos/thephpleague/route/languages","stargazers_url":"https://api.github.com/repos/thephpleague/route/stargazers","contributors_url":"https://api.github.com/repos/thephpleague/route/contributors","subscribers_url":"https://api.github.com/repos/thephpleague/route/subscribers","subscription_url":"https://api.github.com/repos/thephpleague/route/subscription","commits_url":"https://api.github.com/repos/thephpleague/route/commits{/sha}","git_commits_url":"https://api.github.com/repos/thephpleague/route/git/commits{/sha}","comments_url":"https://api.github.com/repos/thephpleague/route/comments{/number}","issue_comment_url":"https://api.github.com/repos/thephpleague/route/issues/comments{/number}","contents_url":"https://api.github.com/repos/thephpleague/route/contents/{+path}","compare_url":"https://api.github.com/repos/thephpleague/route/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thephpleague/route/merges","archive_url":"https://api.github.com/repos/thephpleague/route/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thephpleague/route/downloads","issues_url":"https://api.github.com/repos/thephpleague/route/issues{/number}","pulls_url":"https://api.github.com/repos/thephpleague/route/pulls{/number}","milestones_url":"https://api.github.com/repos/thephpleague/route/milestones{/number}","notifications_url":"https://api.github.com/repos/thephpleague/route/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thephpleague/route/labels{/name}","releases_url":"https://api.github.com/repos/thephpleague/route/releases{/id}","deployments_url":"https://api.github.com/repos/thephpleague/route/deployments","created_at":"2015-01-12T10:21:02Z","updated_at":"2016-04-12T06:35:26Z","pushed_at":"2016-04-13T08:05:32Z","git_url":"git://github.com/thephpleague/route.git","ssh_url":"git@github.com:thephpleague/route.git","clone_url":"https://github.com/thephpleague/route.git","svn_url":"https://github.com/thephpleague/route","homepage":"http://route.thephpleague.com","size":621,"stargazers_count":189,"watchers_count":189,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":38,"mirror_url":null,"open_issues_count":3,"forks":38,"open_issues":3,"watchers":189,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/thephpleague/route/pulls/115"},"html":{"href":"https://github.com/thephpleague/route/pull/115"},"issue":{"href":"https://api.github.com/repos/thephpleague/route/issues/115"},"comments":{"href":"https://api.github.com/repos/thephpleague/route/issues/115/comments"},"review_comments":{"href":"https://api.github.com/repos/thephpleague/route/pulls/115/comments"},"review_comment":{"href":"https://api.github.com/repos/thephpleague/route/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/thephpleague/route/pulls/115/commits"},"statuses":{"href":"https://api.github.com/repos/thephpleague/route/statuses/53f8191c27c6c77466d98d5ae4b118d735c10f9e"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"philipobenito","id":2077289,"avatar_url":"https://avatars.githubusercontent.com/u/2077289?v=3","gravatar_id":"","url":"https://api.github.com/users/philipobenito","html_url":"https://github.com/philipobenito","followers_url":"https://api.github.com/users/philipobenito/followers","following_url":"https://api.github.com/users/philipobenito/following{/other_user}","gists_url":"https://api.github.com/users/philipobenito/gists{/gist_id}","starred_url":"https://api.github.com/users/philipobenito/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philipobenito/subscriptions","organizations_url":"https://api.github.com/users/philipobenito/orgs","repos_url":"https://api.github.com/users/philipobenito/repos","events_url":"https://api.github.com/users/philipobenito/events{/privacy}","received_events_url":"https://api.github.com/users/philipobenito/received_events","type":"User","site_admin":false},"comments":14,"review_comments":2,"commits":16,"additions":923,"deletions":1010,"changed_files":33}}