{"action":"created","issue":{"url":"https://api.github.com/repos/spirit-js/spirit/issues/10","repository_url":"https://api.github.com/repos/spirit-js/spirit","labels_url":"https://api.github.com/repos/spirit-js/spirit/issues/10/labels{/name}","comments_url":"https://api.github.com/repos/spirit-js/spirit/issues/10/comments","events_url":"https://api.github.com/repos/spirit-js/spirit/issues/10/events","html_url":"https://github.com/spirit-js/spirit/issues/10","id":186572000,"number":10,"title":"Return JSON response with custom status code","user":{"login":"ranyefet","id":1016375,"avatar_url":"https://avatars.githubusercontent.com/u/1016375?v=3","gravatar_id":"","url":"https://api.github.com/users/ranyefet","html_url":"https://github.com/ranyefet","followers_url":"https://api.github.com/users/ranyefet/followers","following_url":"https://api.github.com/users/ranyefet/following{/other_user}","gists_url":"https://api.github.com/users/ranyefet/gists{/gist_id}","starred_url":"https://api.github.com/users/ranyefet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ranyefet/subscriptions","organizations_url":"https://api.github.com/users/ranyefet/orgs","repos_url":"https://api.github.com/users/ranyefet/repos","events_url":"https://api.github.com/users/ranyefet/events{/privacy}","received_events_url":"https://api.github.com/users/ranyefet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-01T16:00:10Z","updated_at":"2016-11-01T18:33:11Z","closed_at":null,"body":"Hello,\r\n\r\nI'm building a JSON api using spirit.\r\nI've started by adding catch-all route to return 404 response.\r\n\r\n```javascript\r\nroute.get(\"*\", {\r\n  status: 404,\r\n  headers: {\r\n    'Content-Type': 'application/json'\r\n  }\r\n    body: JSON.stringify({\r\n    message: 'Not Found',\r\n  })\r\n})\r\n```\r\n\r\nWhile it works, it's a little bit verbose. \r\n\r\nIs there a shorter way to do that, maybe something like:\r\n```javascript\r\nroute.get(\"*\", response.json(404, { message: \"Not Found\" }))\r\n```\r\n\r\nThanks,\r\nRan."},"comment":{"url":"https://api.github.com/repos/spirit-js/spirit/issues/comments/257653501","html_url":"https://github.com/spirit-js/spirit/issues/10#issuecomment-257653501","issue_url":"https://api.github.com/repos/spirit-js/spirit/issues/10","id":257653501,"user":{"login":"dodekeract","id":1133858,"avatar_url":"https://avatars.githubusercontent.com/u/1133858?v=3","gravatar_id":"","url":"https://api.github.com/users/dodekeract","html_url":"https://github.com/dodekeract","followers_url":"https://api.github.com/users/dodekeract/followers","following_url":"https://api.github.com/users/dodekeract/following{/other_user}","gists_url":"https://api.github.com/users/dodekeract/gists{/gist_id}","starred_url":"https://api.github.com/users/dodekeract/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dodekeract/subscriptions","organizations_url":"https://api.github.com/users/dodekeract/orgs","repos_url":"https://api.github.com/users/dodekeract/repos","events_url":"https://api.github.com/users/dodekeract/events{/privacy}","received_events_url":"https://api.github.com/users/dodekeract/received_events","type":"User","site_admin":false},"created_at":"2016-11-01T18:33:11Z","updated_at":"2016-11-01T18:33:11Z","body":"Why don't you implement `response.json` like this?\r\n\r\n```javascript\r\nconst response = {\r\n\tjson: (status, body) {\r\n\t\treturn {\r\n\t\t\tstatus,\r\n\t\t\theaders: {\r\n\t\t\t\t'Content-Type': 'application/json'\r\n\t\t\t},\r\n\t\t\tbody\r\n\t\t};\r\n\t}\r\n};\r\n```"}}
{"actor":{"display_login":"dodekeract"}}