Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ProtoRPC & REST

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?

like image 474
Sergei Basharov Avatar asked May 18 '11 07:05

Sergei Basharov


2 Answers

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.

like image 173
Drew Sears Avatar answered Nov 05 '22 09:11

Drew Sears


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

Github (Docs)

like image 40
user1438003 Avatar answered Nov 05 '22 09:11

user1438003