I have an existing RESTful API wich can't be changed. Now, i'm working on the webclient.
I would like to use a library like backbone.js (for the first time).
Here is the design of the existing API
1.) GET /persons
- Returns the whole collection of persons
2.) GET /persons?p1=a&p2=b
(e.g.) - Returns a subset of the complete collection which matches the criteria specified by the query parameters
3.) GET /persons/[id]
- Returns a person by id
4.) POST /persons
- modifies the collection (e.g. creates a new person) and returns the specific result
Issues:
The problem with #1 (and #2): The output format is like this:
{size: 1, persons: [{'id': 1, 'firstname': 'foo', 'lastname': 'bar'}]}
The problem with #2: how to map such a requst to backbone.js?
Any suggestions?