mckoss / gdg-tablet-bootcamp

Google Developer Group sample Tablet Web App
5 stars 39 forks source link

App Engine Cloud Endpoints (rest) #1

Open branflake2267 opened 11 years ago

branflake2267 commented 11 years ago

Just a thought, but I was testing App Engine cloud endpoints and it works nice as a rest server. Of course this is in Java and maybe not a hot button but it is quite nice to setup for any client backend. :)

Here is my tests for the calls to the end points for the example I'm working on. https://github.com/branflake2267/DartRestWithJavaCloudEndpoints/blob/master/RestServerCloudEndpoints/test/org/gonevertical/server/PersonEndpointTest.java

If this is of interest, one would need to sign up for the tester program.

Brandon

branflake2267 commented 11 years ago

Here is the production link: https://democloudpoint.appspot.com/

mckoss commented 11 years ago

The code you sent me does not look like a rest endpoint to me. That is because it uses verbs like get and insert and update. Arrest in point is 1 that is defined using http verbs like get and put and post.

You will note that the sample that we are going to give at the gdg demo fest is a true rest endpoint you written in Python. On Sep 2, 2012 11:46 AM, "Brandon Donnelson" notifications@github.com wrote:

Just a thought, but I was testing App Engine cloud endpoints and it works nice as a rest server. Of course this is in Java and maybe not a hot button but it is quite nice to setup for any client backend. :)

Here is my tests for the calls to the end points for the example I'm working on.

https://github.com/branflake2267/DartRestWithJavaCloudEndpoints/blob/master/RestServerCloudEndpoints/test/org/gonevertical/server/PersonEndpointTest.java

If this is of interest, one would need to sign up for the tester program.

Brandon

— Reply to this email directly or view it on GitHubhttps://github.com/mckoss/gdg-tablet-bootcamp/issues/1.

branflake2267 commented 11 years ago

Good points. What you see is in the above is the java api that gets converted into the verbs your stating :) I might need to adjust the annotations to match the verbs better :) Then again, maybe this api doesn't match the rest pattern exactly.

Nice work on the demo and rest points ;)

This is better at describing the methods. https://github.com/branflake2267/DartRestWithJavaCloudEndpoints/blob/master/RestServerCloudEndpoints/war/WEB-INF/animalendpoint-v1.api

Here is someone who drew up some docs for android backend. http://devthots.blogspot.com/2012/07/building-awesome-android-apps-with.html

mckoss commented 11 years ago

If you look at the definition of REST URLs are used to represent objects or resources. Then http verbs used to access them or modify them. On Sep 2, 2012 5:19 PM, "Brandon Donnelson" notifications@github.com wrote:

Good points. What you see is in the above is the java api that gets converted into the verbs your stating :) I might need to adjust the annotations to match the verbs better :) Then again, maybe this api doesn't match the rest pattern exactly.

Nice work on the demo and rest points ;)

This is better at describing the methods.

https://github.com/branflake2267/DartRestWithJavaCloudEndpoints/blob/master/RestServerCloudEndpoints/war/WEB-INF/animalendpoint-v1.api

Here is someone who drew up some docs for android backend.

http://devthots.blogspot.com/2012/07/building-awesome-android-apps-with.html

— Reply to this email directly or view it on GitHubhttps://github.com/mckoss/gdg-tablet-bootcamp/issues/1#issuecomment-8227615.

branflake2267 commented 11 years ago

Yep, thats what the app engine cloud endpoints do. :) They allow you to access and manipulate the resource (entity) through the api. I'm not wanting to sidetrack your goals, I was mentioning this b/c I thought it could be a nice rest option and a api that will be coming out in the near future for app engine. But it sounds like you want to aim to use the framework you provide for the event, which is fine with me :)

Here's how the request looks to insert the Person entity.

insert request: curl -H 'Content-Type: application/json' -d '{ "nameFirst": "Brandon" }' http://localhost:8888/_ah/api/personendpoint/v1/person/insert

response: { "id" : 11, "nameFirst" : "Brandon", "nameLast" : null }

list request curl http://localhost:8888/_ah/api/personendpoint/v1/person/list?limit=2

list response: { "items" : [ { "id" : 1, "nameFirst" : "Brandon", "nameLast" : null }, { "id" : 2, "nameFirst" : "Brandon", "nameLast" : "Donnelson" } ], "nextPageToken" : "E-ABAIICHmoOZGVtb2Nsb3VkcG9pbnRyDAsSBlBlcnNvbhgCDBQ" }

mckoss commented 11 years ago

I'm not a java dev. As far as I can tell this endpoints library is a java only solution.

On scripting languages, without strong typing, there is no need for a library like this. A simple Ajax request can retrieve any resource without the need for a wrapper library.

The need for libs like thus is one reason I'm not a java fan.

I think you'll see how much simpler the solution I'm presenting is - and accomplishes the same result with no needed wrapper code. On Sep 2, 2012 6:20 PM, "Brandon Donnelson" notifications@github.com wrote:

Yep, thats what the app engine cloud endpoints do. :) They allow you to access and manipulate the resource (entity) through the api. I'm not wanting to sidetrack your goals, I was mentioning this b/c I thought it could be a nice rest option and a api that will be coming out in the near future for app engine. But it sounds like you want to aim to use the framework you provide for the event, which is fine with me :)

Here's how the request looks to insert the Person entity.

insert request: curl -H 'Content-Type: application/json' -d '{ "nameFirst": "Brandon" }' http://localhost:8888/_ah/api/personendpoint/v1/person/insert

response: { "id" : 11, "nameFirst" : "Brandon", "nameLast" : null }

list request curl http://localhost:8888/_ah/api/personendpoint/v1/person/list?limit=2

list response: { "items" : [ { "id" : 1, "nameFirst" : "Brandon", "nameLast" : null }, { "id" : 2, "nameFirst" : "Brandon", "nameLast" : "Donnelson" } ], "nextPageToken" : "E-ABAIICHmoOZGVtb2Nsb3VkcG9pbnRyDAsSBlBlcnNvbhgCDBQ" }

— Reply to this email directly or view it on GitHubhttps://github.com/mckoss/gdg-tablet-bootcamp/issues/1#issuecomment-8228009.

branflake2267 commented 11 years ago

I can see where your going with that. Good point.

Ah, this isn't a wrapper like GWT or I should say the only thing its wrapping is datastore calls in app engine war directory on the server side. I think it would be similar to your python serving, but I'm sure your hand crafted solution will be awesome. :) I was thinking this could do some resource serving on the server side, and the client side code can be anything that can interpret json objects. :)