{"action":"created","issue":{"url":"https://api.github.com/repos/OptimalBits/redbird/issues/8","labels_url":"https://api.github.com/repos/OptimalBits/redbird/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/OptimalBits/redbird/issues/8/comments","events_url":"https://api.github.com/repos/OptimalBits/redbird/issues/8/events","html_url":"https://github.com/OptimalBits/redbird/pull/8","id":45706057,"number":8,"title":"Register and proxy to a custom function","user":{"login":"tcoats","id":794222,"avatar_url":"https://avatars.githubusercontent.com/u/794222?v=3","gravatar_id":"","url":"https://api.github.com/users/tcoats","html_url":"https://github.com/tcoats","followers_url":"https://api.github.com/users/tcoats/followers","following_url":"https://api.github.com/users/tcoats/following{/other_user}","gists_url":"https://api.github.com/users/tcoats/gists{/gist_id}","starred_url":"https://api.github.com/users/tcoats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tcoats/subscriptions","organizations_url":"https://api.github.com/users/tcoats/orgs","repos_url":"https://api.github.com/users/tcoats/repos","events_url":"https://api.github.com/users/tcoats/events{/privacy}","received_events_url":"https://api.github.com/users/tcoats/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2014-10-14T02:27:46Z","updated_at":"2015-01-08T22:26:25Z","closed_at":"2015-01-08T22:26:25Z","pull_request":{"url":"https://api.github.com/repos/OptimalBits/redbird/pulls/8","html_url":"https://github.com/OptimalBits/redbird/pull/8","diff_url":"https://github.com/OptimalBits/redbird/pull/8.diff","patch_url":"https://github.com/OptimalBits/redbird/pull/8.patch"},"body":"Logging requests, checking permissions and other use cases require a custom function for every request going through redbird. This pull request adds the following syntax:\r\n\r\n```js\r\nredbird.register('example.com', function(req, res, proxy) {\r\n\tproxy.web(req, res, {target: 'http://192.168.1.2:8080/'});\r\n});\r\n```\r\nWhich is equivalent to:\r\n```js\r\nredbird.register('example.com', '192.168.1.2:8080');\r\n```\r\n\r\nHowever with the new syntax we are able to return a 404, perform permission checking or proxy to a different url per request.\r\n\r\nInternally the array is still called urls, which is something I can cleanup if needed. Also the readme should probably be updated with this new syntax. I'm happy to do both of these if this is a piece of functionality that is welcome in redbird. At the moment there is no parameter to access any options set for the route which may be an addition we want to consider.\r\n\r\nLet me know what you think."},"comment":{"url":"https://api.github.com/repos/OptimalBits/redbird/issues/comments/69261389","html_url":"https://github.com/OptimalBits/redbird/pull/8#issuecomment-69261389","issue_url":"https://api.github.com/repos/OptimalBits/redbird/issues/8","id":69261389,"user":{"login":"tcoats","id":794222,"avatar_url":"https://avatars.githubusercontent.com/u/794222?v=3","gravatar_id":"","url":"https://api.github.com/users/tcoats","html_url":"https://github.com/tcoats","followers_url":"https://api.github.com/users/tcoats/followers","following_url":"https://api.github.com/users/tcoats/following{/other_user}","gists_url":"https://api.github.com/users/tcoats/gists{/gist_id}","starred_url":"https://api.github.com/users/tcoats/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tcoats/subscriptions","organizations_url":"https://api.github.com/users/tcoats/orgs","repos_url":"https://api.github.com/users/tcoats/repos","events_url":"https://api.github.com/users/tcoats/events{/privacy}","received_events_url":"https://api.github.com/users/tcoats/received_events","type":"User","site_admin":false},"created_at":"2015-01-08T22:26:25Z","updated_at":"2015-01-08T22:26:25Z","body":"Custom functions are essential to what we're doing so I took this idea in a new direction.\r\nhttps://github.com/metocean/redwire\r\n\r\nSimilar concept to redbird but with a completely different architecture.\r\nIt supports tcp and tls proxying as well.\r\nFeedback is most welcome."}}