|
| 1 | +#Application base prototype for RESTful-Java-GAE |
| 2 | + |
| 3 | +This is a base prototype demo for setting up an infrastructure for a RESTful Java application, with a Google App Engine backend API talking to DataStore. |
| 4 | + |
| 5 | +## Why |
| 6 | + |
| 7 | +When I initially work with Google App Engine with RESTful API, I walk through lot of resources. |
| 8 | +Unfortunately I could not find out any concrete code to explain RESTful in GAE with Java. |
| 9 | + |
| 10 | +Finally, I found [resftul-webshop](https://github.com/oscarrenalias/restful-webshop) which provides me a sample code to work with RESTful APIs in GAE. Thanks to [Oscar Renalias](https://github.com/oscarrenalias). |
| 11 | +Then I made some changes to make my application to work with RESTful APIs. Here, I just put my learnings in template code. |
| 12 | + |
| 13 | +## USAGE |
| 14 | + |
| 15 | +To start, |
| 16 | + * Just clone this repository |
| 17 | + * From Eclipse, Import this repository as 'Existing Projects into Workspace'. |
| 18 | + |
| 19 | +##Bookmark Application |
| 20 | + |
| 21 | +This is simple Bookmarking application where you create, retrieve, update, delete bookmarks. |
| 22 | + |
| 23 | +There are five RESTful APIs provided |
| 24 | + |
| 25 | + 1. POST /bookmark - Create new bookmark |
| 26 | + 2. GET /bookmarks - Get all bookmarks |
| 27 | + 3. GET /bookmarks/:id - Get particular bookmark |
| 28 | + 4. PUT /bookmarks/:id - Update particular bookmark |
| 29 | + 5. DELETE /bookmarks:id - Delete particular bookmark |
| 30 | + |
| 31 | +I haven't done any pages to test above APIs. You have to use `curl` tool or your browser to test the APIs. |
| 32 | +While testing with JSON data, I highly recommend you to use PrettyJSON tool. Simply you can pipe the output to Python JSON tool( | python -mjson.tool). |
| 33 | +In below sample, I use default GAE `url` as http://localhost:8888. |
| 34 | + |
| 35 | +###POST /bookmark |
| 36 | + |
| 37 | + $ curl -H 'Content-Type: application/json' -d '{"url":"http://github.com", "name":"GitHub", "description" : "Long Live Opensource" }' http://localhost:8888/api/v1/bookmarks |
| 38 | + $ curl -H 'Content-Type: application/json' -d '{"url":"http://google.com", "name":"Google", "description" : "Do not be Evil" }' http://localhost:8888/api/v1/bookmarks |
| 39 | + |
| 40 | +###GET /bookmarks |
| 41 | + |
| 42 | + $ curl http://localhost:8888/api/v1/bookmarks |
| 43 | + |
| 44 | +###GET /bookmarks/:id |
| 45 | + $ curl http://localhost:8888/api/v1/bookmarks/1590 |
| 46 | + |
| 47 | + Note: I assume, the id is 1590. You have to place the ID which you got from GET all bookmarks. |
| 48 | + |
| 49 | +###PUT /bookmarks/:id |
| 50 | + |
| 51 | + $ curl -X PUT -H 'Content-Type: application/json' -d '{"url":"http://github.com", "name":"GitHub(Public)", "description" : "Long Live GitHub Public Repositories" }' http://localhost:8888/api/v1/bookmarks/1590 |
| 52 | + |
| 53 | +###DELETE /bookmarks:id |
| 54 | + |
| 55 | + $ curl -X DELETE http://localhost:8888/api/v1/bookmarks/1590 |
| 56 | + |
| 57 | + |
| 58 | +##Appendix |
| 59 | +It is under MIT License. |
| 60 | +Feel free to fork it and give pull requests. |
| 61 | + |
| 62 | +Long Live Open Source |
0 commit comments