{"action":"created","issue":{"url":"https://api.github.com/repos/samselikoff/ember-cli-mirage/issues/89","labels_url":"https://api.github.com/repos/samselikoff/ember-cli-mirage/issues/89/labels{/name}","comments_url":"https://api.github.com/repos/samselikoff/ember-cli-mirage/issues/89/comments","events_url":"https://api.github.com/repos/samselikoff/ember-cli-mirage/issues/89/events","html_url":"https://github.com/samselikoff/ember-cli-mirage/issues/89","id":67605500,"number":89,"title":"Allow customHandlers to determine the http status code.","user":{"login":"cibernox","id":265339,"avatar_url":"https://avatars.githubusercontent.com/u/265339?v=3","gravatar_id":"","url":"https://api.github.com/users/cibernox","html_url":"https://github.com/cibernox","followers_url":"https://api.github.com/users/cibernox/followers","following_url":"https://api.github.com/users/cibernox/following{/other_user}","gists_url":"https://api.github.com/users/cibernox/gists{/gist_id}","starred_url":"https://api.github.com/users/cibernox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cibernox/subscriptions","organizations_url":"https://api.github.com/users/cibernox/orgs","repos_url":"https://api.github.com/users/cibernox/repos","events_url":"https://api.github.com/users/cibernox/events{/privacy}","received_events_url":"https://api.github.com/users/cibernox/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-04-10T14:16:36Z","updated_at":"2015-04-10T14:31:50Z","closed_at":"2015-04-10T14:28:43Z","body":"I dove into the docs and the code and I haven't found any way of customizing the response code in custom handlers. I think it's not possible right now.\r\n\r\nWhat I'd like to do:\r\n\r\n```js\r\n  this.post('/posts', function (db, request) {\r\n    let data = JSON.parse(request.requestBody);\r\n    if (!data.post.title) {\r\n      return [ 422, {\r\n        errors: { title: [\"can't be blank\"] }\r\n      }];\r\n    }\r\n  });\r\n```\r\n\r\nSeems reasonable to asume that if a custom handler returns a tuple (an array with 2 elements in which the first one is a number in the status-code range 100..599) you're customising the status code. \r\nI suggested a tuple because it similar to the rack behaviour many people already knows.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/samselikoff/ember-cli-mirage/issues/comments/91575775","html_url":"https://github.com/samselikoff/ember-cli-mirage/issues/89#issuecomment-91575775","issue_url":"https://api.github.com/repos/samselikoff/ember-cli-mirage/issues/89","id":91575775,"user":{"login":"samselikoff","id":2922250,"avatar_url":"https://avatars.githubusercontent.com/u/2922250?v=3","gravatar_id":"","url":"https://api.github.com/users/samselikoff","html_url":"https://github.com/samselikoff","followers_url":"https://api.github.com/users/samselikoff/followers","following_url":"https://api.github.com/users/samselikoff/following{/other_user}","gists_url":"https://api.github.com/users/samselikoff/gists{/gist_id}","starred_url":"https://api.github.com/users/samselikoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samselikoff/subscriptions","organizations_url":"https://api.github.com/users/samselikoff/orgs","repos_url":"https://api.github.com/users/samselikoff/repos","events_url":"https://api.github.com/users/samselikoff/events{/privacy}","received_events_url":"https://api.github.com/users/samselikoff/received_events","type":"User","site_admin":false},"created_at":"2015-04-10T14:31:50Z","updated_at":"2015-04-10T14:31:50Z","body":"np, good to know others want it though. For now you can override your route in tests to test the error response. But we'll definitely have an answer to this soon."}}