{"action":"opened","issue":{"url":"https://api.github.com/repos/strongloop/loopback/issues/1777","labels_url":"https://api.github.com/repos/strongloop/loopback/issues/1777/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/1777/comments","events_url":"https://api.github.com/repos/strongloop/loopback/issues/1777/events","html_url":"https://github.com/strongloop/loopback/issues/1777","id":113666786,"number":1777,"title":"adding route specific middleware","user":{"login":"iblazevic","id":1262475,"avatar_url":"https://avatars.githubusercontent.com/u/1262475?v=3","gravatar_id":"","url":"https://api.github.com/users/iblazevic","html_url":"https://github.com/iblazevic","followers_url":"https://api.github.com/users/iblazevic/followers","following_url":"https://api.github.com/users/iblazevic/following{/other_user}","gists_url":"https://api.github.com/users/iblazevic/gists{/gist_id}","starred_url":"https://api.github.com/users/iblazevic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iblazevic/subscriptions","organizations_url":"https://api.github.com/users/iblazevic/orgs","repos_url":"https://api.github.com/users/iblazevic/repos","events_url":"https://api.github.com/users/iblazevic/events{/privacy}","received_events_url":"https://api.github.com/users/iblazevic/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-27T19:46:34Z","updated_at":"2015-10-27T19:46:34Z","closed_at":null,"body":"I've read through documentation and couldn't find a solid example on how to exactly add route specific middleware.\r\n\r\nTo illustrate what that means, we have custom authorization middleware that we had to make for this specific project and its configurable for specific routes.\r\n\r\nIn express it would look something like this:\r\n\r\n    router.route('/someRoute')\r\n      .get(\r\n        customAuthorize(customParams1),\r\n        someController1\r\n      )\r\n      .post(\r\n        customAuthorize(customParams2),\r\n        someController2\r\n      );\r\n\r\nHowever, in the documentation its not really clear whats the best way to do it.\r\n\r\nMost obvious way seems to be to use remote hooks, I'm just wondering is that the best approach for this is something like this:\r\n\r\n    module.exports = function(Review) {\r\n      Review.beforeRemote('create', customAuthorize(customParams1));\r\n    };\r\n\r\nCan someone please confirm this is the right way, and could we put it somewhere in the documentation for future.\r\n\r\nThanks\r\n\r\n"}}