iron-ajax
iron-ajax copied to clipboard
Create a RESTful controller
Iron-ajax is useful, as far as it goes, but it would be even more useful if it could be used directly as a RESTful controller. This means:
(1) Direct support for REST verbs
GET /books index GET /books/create create POST /books save GET /books/${id} show GET /books/${id}/edit edit PUT /books/${id} update PATCH /books/${id} patch DELETE /books/${id} delete
(2) Support for appropriate URL building (usually just appending the object ID to the URL).
(3) Support for both Array and Object models. When you invoke the GET verb without an ID, it assumes that you want all values of that object. When you invoke it with an ID, it assumes that you want just that specific object.
You would typically use it like this:
<iron-controller url="/books" model="{{model}}"></iron-controller>
...
controller.list(); // would list all of the objects.
controller.update(); // would update the object whose model is currently bound to the controller.
controller.patch(); // would do a partial update of the object.
Something like this exists in this repo. I haven't used it so can't comment on the API or usability.