The example is using /cars
as the resource to interact with.
The following route has been added to the demo:
route() .from("/cars") .on(RequestMethod.GET) .produces(MediaType.JSON) .to(Cars.class).get(param("offset", "0"), param("limit", "-1"));
From this we can see that there are two optional parameters, offset
and limit
. If these are not specified all cars will be returned.
curl -i --header "Accept: application/json" "http://controllerdemo-danbev.rhcloud.com/aerogear-controller-demo/cars?offset=0&limit=4"
The request will return:
HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 Content-Length: 160 AG-Paging-Offset: 0 AG-Paging-Limit: 4 AG-Paging-Total: 4 AG-Links-Next: cars?offset=1&limit=4 AG-Links-Last: cars?offset=3&limit=4 [ {"color":"Green","brand":"Audi","id":1}, {"color":"White","brand":"Audi","id":2}, {"color":"Black","brand":"Audi","id":3}, {"color":"Black","brand":"BMW","id":4} ]
To get the next page you can follow the next
link:
curl -i --header "Accept: application/json" "http://controllerdemo-danbev.rhcloud.com/aerogear-controller-demo/cars?offset=1&limit=4"
HTTP/1.1 200 OK Content-Type: application/json;charset=UTF-8 Content-Length: 166 AG-Paging-Offset: 1 AG-Paging-Limit: 4 AG-Paging-Total: 4 AG-Links-First: cars?offset=0&limit=4 AG-Links-Previous: cars?offset=0&limit=4 AG-Links-Next: cars?offset=2&limit=4 AG-Links-Last: cars?offset=3&limit=4 [ {"color":"Green","brand":"BMW","id":5}, {"color":"Red","brand":"Ferrari","id":6}, {"color":"White","brand":"Ferrari","id":7}, {"color":"Pink","brand":"Ferrari","id":8} ]
curl -i --header "Accept: application/json" "http://controllerdemo-danbev.rhcloud.com/aerogear-controller-demo/cars"
This request will return:
[ {"color":"Green","brand":"Audi","id":1}, {"color":"White","brand":"Audi","id":2}, {"color":"Black","brand":"Audi","id":3}, {"color":"Black","brand":"BMW","id":4}, {"color":"Green","brand":"BMW","id":5}, {"color":"Red","brand":"Ferrari","id":6}, {"color":"White","brand":"Ferrari","id":7}, {"color":"Pink","brand":"Ferrari","id":8}, {"color":"White","brand":"Golf","id":15}, {"color":"Brown","brand":"Lada","id":16}, {"color":"Orange","brand":"Mazda","id":14}, {"color":"Pink","brand":"Mini","id":13}, {"color":"Gray","brand":"Nissan","id":11}, {"color":"Yello","brand":"Opel","id":10}, {"color":"Blue","brand":"Scoda","id":9}, {"color":"Red","brand":"Volvo","id":12} ]
curl -i --header "Accept: application/json" "http://controllerdemo-danbev.rhcloud.com/aerogear-controller-demo/cars/1"
The request will return:
{"color":"Green","brand":"Audi","id":1}
Great, lets go with 'AG-' prefix then.On 11 January 2013 18:24, Douglas Campos <qmx@qmx.me> wrote:
d'oh, +1 - thought I've typed it…
On 11/01/2013, at 15:10, Kris Borchers <kris@redhat.com> wrote:
> I guess what I meant is I'm not specifically +1 for X- prefix but just some sort of prefix in general. It just makes it easier for devs when looking through headers to see what is being sent. Even something like AG- or AeroGear- would be better IMO than no prefix.
AG- looks nicer - less bandwidth ;)
-- qmx
_______________________________________________
aerogear-dev mailing list
aerogear-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/aerogear-dev