ActionCable在Rails 5 RESTful API开发中的应用?[英] ActionCable usage in Rails 5 RESTful API Development?

本文是小编为大家收集整理的关于ActionCable在Rails 5 RESTful API开发中的应用?的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

我试图第一次创建RESTful API.

使用动作电缆向响应(客户端到服务器)和响应(服务器到客户端).

如何从其他应用程序发送请求(如android/ios app,web app'n或桌面app'n)并响应应用程序.

我在普通Web应用程序中使用了动作电缆.

请向我提供带有ActureCable使用指南的链接5 RESTFUR API.

提前感谢.

推荐答案

以下是使用动作电缆作为RESTful API的详细信息.

  1. 在JSON后使用订阅.

    { "命令":"订阅", "标识符":{ "频道":"chanel_name" }

  2. 在JSON进行模型订阅后使用.

    { "命令":"订阅", "标识符":{ "频道":"chanel_name", "post_id":1 }

  3. 在JSON之后使用通道中的任何方法.

    { "命令":"消息", "标识符":{ "频道":"chanel_name" }, "数据": { "动作":"action_name", .... }

本文地址:https://www.itbaoku.cn/post/1937852.html

问题描述

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.

  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", .... } }