[aerogear-dev] Paging Demo

Daniel Bevenius daniel.bevenius at gmail.com
Sun Jan 13 06:09:39 EST 2013


I've updated the demo and think I've included all the requests.
* Pre-populate the database upon deployment of demo.
* Use 'offset/limit' instead of 'page/perPage'.
* Use 'AG-' prefix for headers.

Let me know if you are missing anything, or would like something done in a
different way.
Use case

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.
<https://gist.github.com/4500336#getting-a-page-of-cars>Getting a page of
Cars

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 OKContent-Type:
application/json;charset=UTF-8Content-Length: 160AG-Paging-Offset:
0AG-Paging-Limit: 4AG-Paging-Total: 4AG-Links-Next:
cars?offset=1&limit=4AG-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}]

<https://gist.github.com/4500336#getting-the-next-page-of-cars>Getting the
next page of Cars

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 OKContent-Type:
application/json;charset=UTF-8Content-Length: 166AG-Paging-Offset:
1AG-Paging-Limit: 4AG-Paging-Total: 4AG-Links-First:
cars?offset=0&limit=4AG-Links-Previous:
cars?offset=0&limit=4AG-Links-Next:
cars?offset=2&limit=4AG-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}]

<https://gist.github.com/4500336#get-all-cars>Get all Cars

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}]

<https://gist.github.com/4500336#get-a-single-car>Get a single Car

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}



On 12 January 2013 11:08, Daniel Bevenius <daniel.bevenius at gmail.com> wrote:

> Great, lets go with 'AG-' prefix then.
>
>
>
>
> On 11 January 2013 18:24, Douglas Campos <qmx at qmx.me> wrote:
>
>>
>> On 11/01/2013, at 15:10, Kris Borchers <kris at 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.
>>
>> d'oh, +1 - thought I've typed it…
>>
>> AG- looks nicer - less bandwidth ;)
>>
>> -- qmx
>> _______________________________________________
>> aerogear-dev mailing list
>> aerogear-dev at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/aerogear-dev
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/aerogear-dev/attachments/20130113/cee45292/attachment-0001.html 


More information about the aerogear-dev mailing list