ActionCable usage in Rails 5 RESTful API Development?

社会主义新天地 提交于 2019-12-23 03:43:09

问题


I am trying to create a RESTful API for the first time.

Sending Request(Client to Server) and Response(Server to Client) using Action Cable.

How to send request from other Applications(like Android/iOS App, Web App'n or Desktop App'n) and give response to the application.

I have used Action Cable in normal Web Application.

Please provide me some links with guides of ActionCable usage in Rails 5 RESTful API.

Thanks in Advance.


回答1:


Here is the detail to use Action Cable as Restful API.

  1. Use following JSON for subscription.

    { "command": "subscribe", "identifier": { "channel": "CHANEL_NAME" } }

  2. Use following JSON for model subscription.

    { "command": "subscribe", "identifier": { "channel": "CHANEL_NAME", "post_id": 1 } }

  3. Use following JSON to call any method in channel.

    { "command": "message", "identifier": { "channel": "CHANEL_NAME" }, "data": { "action": "ACTION_NAME", .... } }



来源:https://stackoverflow.com/questions/39608501/actioncable-usage-in-rails-5-restful-api-development

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!