ProtoRPC 和休息

发布于 2024-11-08 03:27:54 字数 473 浏览 0 评论 0原文

我尝试使用 ProtoRPC,我真的很喜欢添加方法、修改字段的轻松程度,以及我的应用程序代码看起来多么可靠和结构化。
现在我正在使用 Backbone.js 并喜欢它的想法;我认为 Backbone 通过 REST 提供 CRUD 作为处理远程数据源的首选方法。
我知道它允许我重新定义 Backbone.sync 以使其适合我的需求。

不过,我不确定将 Backbone 和 ProtoRPC 连接在一起的更好方法是什么。如果我有 ProtoRPC 并且它运行完美,我也不认为我需要创建 RESTful 服务器端服务。

您能否分享一下您的想法,如何更好地让所有这些东西一起工作并快乐?

I tried working with ProtoRPC and I really like how easily I can add methods, modify fields, and how solid and structured my app code looks with this.
Now I am playing with Backbone.js and like its idea; I see Backbone offers CRUD through REST as its preferable method to work with remote data source.
I know it allows me to redefine Backbone.sync to make it suitable for my needs.

Though, I am not sure what is a better approach to join Backbone and ProtoRPC together. I also don't think I need to make a RESTful server-side service if I have ProtoRPC and it works perfect.

Could you please share your ideas how to better make this all stuff work together and happy?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ぃ双果 2024-11-15 03:27:54

REST 和 RPC 的区别相当显着。我建议不要尝试将 REST 客户端与 RPC 服务器结合起来。

使用 ProtoRPC,每个方法都有一个不同的端点。每个端点通过 HTTP POST 以 JSON 字典的形式接受格式良好的消息,成功后返回格式良好的响应字典和 HTTP 200。使用 REST,每个端点应代表一个资源或资源集合。您的 HTTP 动词应指示所需的操作,您的请求和响应正文应填充资源的完整表示或根本不填充任何内容,并且服务器的 HTTP 响应代码(即使在成功的情况下)也应根据操作的结果。

看起来 Backbone.js 可以让您在 HTTP 动词上滑动,但除此之外,它需要一个兼容 REST 的服务器。如果您打算使用 Backbone.js,则可能需要跳过 ProtoRPC 并使用类似 appengine-rest-server

REST and RPC differ rather dramatically. I would advise against trying to marry a REST client to an RPC server.

With ProtoRPC, each method has a distinct endpoint. Each endpoint accepts a well-formed message via HTTP POST in the form of a JSON dictionary, and on success, returns a well-formed response dictionary and an HTTP 200. With REST, each endpoint should represent a resource or a collection of resources. Your HTTP verb should indicate the desired action, your request and response body should be populated with either a full representation of the resource or nothing at all, and the server's HTTP response code, even in the case of a success, should vary based on the result of the operation.

It looks like Backbone.js will let you slide on the HTTP verb, but otherwise, it expects a REST-compliant server. If you're intent on using Backbone.js, you might want to skip ProtoRPC and use something like appengine-rest-server.

两人的回忆 2024-11-15 03:27:54

我知道有点晚了,但似乎有人已经为 Backbone.js 实现了 JSONRPC:

Github (< a href="http://asciidisco.github.com/Backbone.Rpc/index.html" rel="nofollow">文档)

I know it's a little late, but seems someone has implemented JSONRPC for Backbone.js:

Github (Docs)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文