{"action":"closed","issue":{"url":"https://api.github.com/repos/xogroup/toki/issues/16","repository_url":"https://api.github.com/repos/xogroup/toki","labels_url":"https://api.github.com/repos/xogroup/toki/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/xogroup/toki/issues/16/comments","events_url":"https://api.github.com/repos/xogroup/toki/issues/16/events","html_url":"https://github.com/xogroup/toki/issues/16","id":214210899,"number":16,"title":"Add built-in response sender method","user":{"login":"WesTyler","id":12154939,"avatar_url":"https://avatars2.githubusercontent.com/u/12154939?v=3","gravatar_id":"","url":"https://api.github.com/users/WesTyler","html_url":"https://github.com/WesTyler","followers_url":"https://api.github.com/users/WesTyler/followers","following_url":"https://api.github.com/users/WesTyler/following{/other_user}","gists_url":"https://api.github.com/users/WesTyler/gists{/gist_id}","starred_url":"https://api.github.com/users/WesTyler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WesTyler/subscriptions","organizations_url":"https://api.github.com/users/WesTyler/orgs","repos_url":"https://api.github.com/users/WesTyler/repos","events_url":"https://api.github.com/users/WesTyler/events{/privacy}","received_events_url":"https://api.github.com/users/WesTyler/received_events","type":"User","site_admin":false},"labels":[{"id":536735966,"url":"https://api.github.com/repos/xogroup/toki/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"closed","locked":false,"assignee":{"login":"WesTyler","id":12154939,"avatar_url":"https://avatars2.githubusercontent.com/u/12154939?v=3","gravatar_id":"","url":"https://api.github.com/users/WesTyler","html_url":"https://github.com/WesTyler","followers_url":"https://api.github.com/users/WesTyler/followers","following_url":"https://api.github.com/users/WesTyler/following{/other_user}","gists_url":"https://api.github.com/users/WesTyler/gists{/gist_id}","starred_url":"https://api.github.com/users/WesTyler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WesTyler/subscriptions","organizations_url":"https://api.github.com/users/WesTyler/orgs","repos_url":"https://api.github.com/users/WesTyler/repos","events_url":"https://api.github.com/users/WesTyler/events{/privacy}","received_events_url":"https://api.github.com/users/WesTyler/received_events","type":"User","site_admin":false},"assignees":[{"login":"WesTyler","id":12154939,"avatar_url":"https://avatars2.githubusercontent.com/u/12154939?v=3","gravatar_id":"","url":"https://api.github.com/users/WesTyler","html_url":"https://github.com/WesTyler","followers_url":"https://api.github.com/users/WesTyler/followers","following_url":"https://api.github.com/users/WesTyler/following{/other_user}","gists_url":"https://api.github.com/users/WesTyler/gists{/gist_id}","starred_url":"https://api.github.com/users/WesTyler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/WesTyler/subscriptions","organizations_url":"https://api.github.com/users/WesTyler/orgs","repos_url":"https://api.github.com/users/WesTyler/repos","events_url":"https://api.github.com/users/WesTyler/events{/privacy}","received_events_url":"https://api.github.com/users/WesTyler/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2017-03-14T21:23:28Z","updated_at":"2017-03-20T20:49:44Z","closed_at":"2017-03-20T20:49:44Z","body":"#### What are you trying to achieve or the steps to reproduce ?\r\n\r\nSince Toki delegates the responsibility for sending HTTP responses to action methods in all cases except for \"uncaught\" errors (500 Server Error), there should be an action `\"type\"` that indicates that an HTTP response needs to be sent. Methods like `toki-method-proxy` and `toki-method-http` handle the response delegation, but there are use cases (below) in which the action needed is nothing more than a simple HTTP response.\r\n\r\n#### What result did you expect ?\r\nThe contrived \"failure\" ruleset should result in a rabbit event being emitted, then a mapped response being sent back to the client.\r\n```js\r\n\"failure\": [\r\n    {\r\n        \"name\": \"rabbit action\",\r\n        \"type\": \"toki-method-rabbit\",\r\n        \"rabbitConfiguration\": { /*BunnyBus configs*/ },\r\n        \"createConfiguration\": {\r\n            \"event\": \"toki.request-failed\",\r\n            \"message\": {\r\n                \"processed\": false,\r\n                \"errors\": \"{{=it.errors}}\"\r\n            }\r\n        }\r\n    },\r\n    {\r\n        \"name\": \"error response\",\r\n        \"type\": \"responder\",\r\n        \"clientResponse\": {\r\n            \"statusCode\": \"{{=it.errors.designatedStatusCode}}\",\r\n            \"payload\": \"{{=it.errors.optionalPayload}}\"\r\n        }\r\n    }\r\n]\r\n```\r\n\r\n#### What result did you observe ?\r\nSince the built in HTTP responder does not exist, the request hangs open when the \"failure\" ruleset is executed.\r\n\r\n#### Requirements\r\n  - An action (whether in `\"actions\"` or `\"failure\"` rulesets) with the type `\"responder\"` should utilize the build in responder method instead of trying to `require('responder')`.\r\n  - The `clientResponse` should support toki-templater templated payloads.\r\n  - The `clientResponse` config is required and has the following Joi schema:\r\n    ```js\r\n    const responderConfig = Joi.object().keys({\r\n        statusCode: Joi.alternatives().try(Joi.string, Joi.number()).required(),\r\n        payload: Joi.alternatives().try(Joi.string(), Joi.object()).optional()\r\n    }).required();\r\n    ```\r\n  - The HTTP response should be sent with the configured statusCode and, if present, payload.\r\n  - An error in `responder` should result in the default error handler sending back a 500 Server Error response.\r\n"}}
{"actor":{"display_login":"WesTyler"}}