问题
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.
Use following JSON for subscription.
{ "command": "subscribe", "identifier": { "channel": "CHANEL_NAME" } }
Use following JSON for model subscription.
{ "command": "subscribe", "identifier": { "channel": "CHANEL_NAME", "post_id": 1 } }
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