{"action":"opened","number":4,"pull_request":{"url":"https://api.github.com/repos/bardzusny/swaggerize-restify/pulls/4","id":51183050,"html_url":"https://github.com/bardzusny/swaggerize-restify/pull/4","diff_url":"https://github.com/bardzusny/swaggerize-restify/pull/4.diff","patch_url":"https://github.com/bardzusny/swaggerize-restify/pull/4.patch","issue_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/issues/4","number":4,"state":"open","locked":false,"title":"Do not use res.send() inside the module as it breaks middleware chain.","user":{"login":"rochal","id":1065287,"avatar_url":"https://avatars.githubusercontent.com/u/1065287?v=3","gravatar_id":"","url":"https://api.github.com/users/rochal","html_url":"https://github.com/rochal","followers_url":"https://api.github.com/users/rochal/followers","following_url":"https://api.github.com/users/rochal/following{/other_user}","gists_url":"https://api.github.com/users/rochal/gists{/gist_id}","starred_url":"https://api.github.com/users/rochal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rochal/subscriptions","organizations_url":"https://api.github.com/users/rochal/orgs","repos_url":"https://api.github.com/users/rochal/repos","events_url":"https://api.github.com/users/rochal/events{/privacy}","received_events_url":"https://api.github.com/users/rochal/received_events","type":"User","site_admin":false},"body":"Instead, pass error to middleware and let the clients handle / remap the error message / status code in their own error handlers.\r\n\r\nThis way rather than returning empty payload, clients can iterate through the error objects and decorate as needed.\r\n\r\nOnce error is passed down, it could be used in formatters, ex:\r\n\r\n```\r\nvar server = restify.createServer({\r\n    formatters: {\r\n        'application/json': function formatFoo(req, res, body, cb) {\r\n            if (body instanceof Error) {\r\n                return cb(null, JSON.stringify(new restify.errors.InvalidContentError({\r\n                    message: body.message\r\n                }).body));\r\n            } else {\r\n                return cb(null, util.inspect(body));\r\n            }\r\n        }\r\n    }\r\n});\r\n```\r\n\r\nMore info on why we shouldn't be using res.send: https://github.com/restify/node-restify/issues/948\r\nPlus, it will be even easier to catch this in restify 5, with: https://github.com/restify/node-restify/pull/892","created_at":"2015-11-19T05:50:43Z","updated_at":"2015-11-19T05:50:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/pulls/4/commits","review_comments_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/pulls/4/comments","review_comment_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/issues/4/comments","statuses_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/statuses/fb21c1f2af3637e59df5a7d43e7f7d6710a28ccc","head":{"label":"rochal:master","ref":"master","sha":"fb21c1f2af3637e59df5a7d43e7f7d6710a28ccc","user":{"login":"rochal","id":1065287,"avatar_url":"https://avatars.githubusercontent.com/u/1065287?v=3","gravatar_id":"","url":"https://api.github.com/users/rochal","html_url":"https://github.com/rochal","followers_url":"https://api.github.com/users/rochal/followers","following_url":"https://api.github.com/users/rochal/following{/other_user}","gists_url":"https://api.github.com/users/rochal/gists{/gist_id}","starred_url":"https://api.github.com/users/rochal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rochal/subscriptions","organizations_url":"https://api.github.com/users/rochal/orgs","repos_url":"https://api.github.com/users/rochal/repos","events_url":"https://api.github.com/users/rochal/events{/privacy}","received_events_url":"https://api.github.com/users/rochal/received_events","type":"User","site_admin":false},"repo":{"id":46389352,"name":"swaggerize-restify","full_name":"rochal/swaggerize-restify","owner":{"login":"rochal","id":1065287,"avatar_url":"https://avatars.githubusercontent.com/u/1065287?v=3","gravatar_id":"","url":"https://api.github.com/users/rochal","html_url":"https://github.com/rochal","followers_url":"https://api.github.com/users/rochal/followers","following_url":"https://api.github.com/users/rochal/following{/other_user}","gists_url":"https://api.github.com/users/rochal/gists{/gist_id}","starred_url":"https://api.github.com/users/rochal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rochal/subscriptions","organizations_url":"https://api.github.com/users/rochal/orgs","repos_url":"https://api.github.com/users/rochal/repos","events_url":"https://api.github.com/users/rochal/events{/privacy}","received_events_url":"https://api.github.com/users/rochal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rochal/swaggerize-restify","description":"Design-driven apis with swagger 2.0 and restify.","fork":true,"url":"https://api.github.com/repos/rochal/swaggerize-restify","forks_url":"https://api.github.com/repos/rochal/swaggerize-restify/forks","keys_url":"https://api.github.com/repos/rochal/swaggerize-restify/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rochal/swaggerize-restify/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rochal/swaggerize-restify/teams","hooks_url":"https://api.github.com/repos/rochal/swaggerize-restify/hooks","issue_events_url":"https://api.github.com/repos/rochal/swaggerize-restify/issues/events{/number}","events_url":"https://api.github.com/repos/rochal/swaggerize-restify/events","assignees_url":"https://api.github.com/repos/rochal/swaggerize-restify/assignees{/user}","branches_url":"https://api.github.com/repos/rochal/swaggerize-restify/branches{/branch}","tags_url":"https://api.github.com/repos/rochal/swaggerize-restify/tags","blobs_url":"https://api.github.com/repos/rochal/swaggerize-restify/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rochal/swaggerize-restify/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rochal/swaggerize-restify/git/refs{/sha}","trees_url":"https://api.github.com/repos/rochal/swaggerize-restify/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rochal/swaggerize-restify/statuses/{sha}","languages_url":"https://api.github.com/repos/rochal/swaggerize-restify/languages","stargazers_url":"https://api.github.com/repos/rochal/swaggerize-restify/stargazers","contributors_url":"https://api.github.com/repos/rochal/swaggerize-restify/contributors","subscribers_url":"https://api.github.com/repos/rochal/swaggerize-restify/subscribers","subscription_url":"https://api.github.com/repos/rochal/swaggerize-restify/subscription","commits_url":"https://api.github.com/repos/rochal/swaggerize-restify/commits{/sha}","git_commits_url":"https://api.github.com/repos/rochal/swaggerize-restify/git/commits{/sha}","comments_url":"https://api.github.com/repos/rochal/swaggerize-restify/comments{/number}","issue_comment_url":"https://api.github.com/repos/rochal/swaggerize-restify/issues/comments{/number}","contents_url":"https://api.github.com/repos/rochal/swaggerize-restify/contents/{+path}","compare_url":"https://api.github.com/repos/rochal/swaggerize-restify/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rochal/swaggerize-restify/merges","archive_url":"https://api.github.com/repos/rochal/swaggerize-restify/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rochal/swaggerize-restify/downloads","issues_url":"https://api.github.com/repos/rochal/swaggerize-restify/issues{/number}","pulls_url":"https://api.github.com/repos/rochal/swaggerize-restify/pulls{/number}","milestones_url":"https://api.github.com/repos/rochal/swaggerize-restify/milestones{/number}","notifications_url":"https://api.github.com/repos/rochal/swaggerize-restify/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rochal/swaggerize-restify/labels{/name}","releases_url":"https://api.github.com/repos/rochal/swaggerize-restify/releases{/id}","created_at":"2015-11-18T02:21:00Z","updated_at":"2015-11-18T02:21:01Z","pushed_at":"2015-11-19T03:06:03Z","git_url":"git://github.com/rochal/swaggerize-restify.git","ssh_url":"git@github.com:rochal/swaggerize-restify.git","clone_url":"https://github.com/rochal/swaggerize-restify.git","svn_url":"https://github.com/rochal/swaggerize-restify","homepage":"","size":206,"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":"bardzusny:master","ref":"master","sha":"ed69f60a90b1a4b3ef8683d7fcadac41be907968","user":{"login":"bardzusny","id":8849448,"avatar_url":"https://avatars.githubusercontent.com/u/8849448?v=3","gravatar_id":"","url":"https://api.github.com/users/bardzusny","html_url":"https://github.com/bardzusny","followers_url":"https://api.github.com/users/bardzusny/followers","following_url":"https://api.github.com/users/bardzusny/following{/other_user}","gists_url":"https://api.github.com/users/bardzusny/gists{/gist_id}","starred_url":"https://api.github.com/users/bardzusny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bardzusny/subscriptions","organizations_url":"https://api.github.com/users/bardzusny/orgs","repos_url":"https://api.github.com/users/bardzusny/repos","events_url":"https://api.github.com/users/bardzusny/events{/privacy}","received_events_url":"https://api.github.com/users/bardzusny/received_events","type":"User","site_admin":false},"repo":{"id":31193707,"name":"swaggerize-restify","full_name":"bardzusny/swaggerize-restify","owner":{"login":"bardzusny","id":8849448,"avatar_url":"https://avatars.githubusercontent.com/u/8849448?v=3","gravatar_id":"","url":"https://api.github.com/users/bardzusny","html_url":"https://github.com/bardzusny","followers_url":"https://api.github.com/users/bardzusny/followers","following_url":"https://api.github.com/users/bardzusny/following{/other_user}","gists_url":"https://api.github.com/users/bardzusny/gists{/gist_id}","starred_url":"https://api.github.com/users/bardzusny/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bardzusny/subscriptions","organizations_url":"https://api.github.com/users/bardzusny/orgs","repos_url":"https://api.github.com/users/bardzusny/repos","events_url":"https://api.github.com/users/bardzusny/events{/privacy}","received_events_url":"https://api.github.com/users/bardzusny/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bardzusny/swaggerize-restify","description":"Design-driven apis with swagger 2.0 and restify.","fork":true,"url":"https://api.github.com/repos/bardzusny/swaggerize-restify","forks_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/forks","keys_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/teams","hooks_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/hooks","issue_events_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/issues/events{/number}","events_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/events","assignees_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/assignees{/user}","branches_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/branches{/branch}","tags_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/tags","blobs_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/git/refs{/sha}","trees_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/statuses/{sha}","languages_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/languages","stargazers_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/stargazers","contributors_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/contributors","subscribers_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/subscribers","subscription_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/subscription","commits_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/commits{/sha}","git_commits_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/git/commits{/sha}","comments_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/comments{/number}","issue_comment_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/issues/comments{/number}","contents_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/contents/{+path}","compare_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/merges","archive_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/downloads","issues_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/issues{/number}","pulls_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/pulls{/number}","milestones_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/milestones{/number}","notifications_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/labels{/name}","releases_url":"https://api.github.com/repos/bardzusny/swaggerize-restify/releases{/id}","created_at":"2015-02-23T04:17:24Z","updated_at":"2015-11-18T02:20:55Z","pushed_at":"2015-08-22T11:57:26Z","git_url":"git://github.com/bardzusny/swaggerize-restify.git","ssh_url":"git@github.com:bardzusny/swaggerize-restify.git","clone_url":"https://github.com/bardzusny/swaggerize-restify.git","svn_url":"https://github.com/bardzusny/swaggerize-restify","homepage":"","size":344,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":4,"forks":3,"open_issues":4,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bardzusny/swaggerize-restify/pulls/4"},"html":{"href":"https://github.com/bardzusny/swaggerize-restify/pull/4"},"issue":{"href":"https://api.github.com/repos/bardzusny/swaggerize-restify/issues/4"},"comments":{"href":"https://api.github.com/repos/bardzusny/swaggerize-restify/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/bardzusny/swaggerize-restify/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/bardzusny/swaggerize-restify/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bardzusny/swaggerize-restify/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/bardzusny/swaggerize-restify/statuses/fb21c1f2af3637e59df5a7d43e7f7d6710a28ccc"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":1,"deletions":2,"changed_files":2}}