问题描述
我试图第一次创建RESTful API.
使用动作电缆向响应(客户端到服务器)和响应(服务器到客户端).
如何从其他应用程序发送请求(如android/ios app,web app'n或桌面app'n)并响应应用程序.
我在普通Web应用程序中使用了动作电缆.
请向我提供带有ActureCable使用指南的链接5 RESTFUR API.
提前感谢.
推荐答案
以下是使用动作电缆作为RESTful API的详细信息.
问题描述
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.
推荐答案
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", .... } }