[aerogear-dev] Server Side: Paging API with Metadata and Links (was: Re: Paging Demo)
danielbevenius
daniel.bevenius at gmail.com
Sun Jan 20 10:29:41 EST 2013
I've been thinking about this and needed to make an update to the controller
as I hade neglected to support returning query parameters in link headers,
other than those used for paging.
I've looked into Bruno's original suggestion and think it has a huge
advantage in that the target endpoint class does not have to be changed, and
can simply return a List<?>.
route()
.from("/cars")
.on(RequestMethod.GET)
.produces(MediaType.JSON)
.paged().offset())
.to(Cars.class).findCarsBy(param("offset", "0"), param("color"),
param("limit", "10"));
For cases where the parameters 'offset' and 'limit' are named differently
they could be configurable:
route()
.from("/cars")
.on(RequestMethod.GET)
.produces(MediaType.JSON)
.paged().offset("myoffset").limitParamName("mylimit")
.to(Cars.class).findCarsBy(param("offset", "0"), param("color"),
param("limit", "10"));
For now, I've just ignored support for a total as I think we need more time
to investigate a proper solution for it, if we think it should be supported
at all. The problem with having a callback is that in some situations, like
the one above, that callback would also have to take a query parameter(s) so
we'd need to do more work that like it initial idea were it would be
possible to simply specify a name of a no-args method that returned an
int/long.
I've updated the controller-demo on openshift and you can find more
information here:
https://gist.github.com/4500336
cheers,
/Dan
--
View this message in context: http://aerogear-dev.1069024.n5.nabble.com/aerogear-dev-Server-Side-Paging-API-with-Metadata-and-Links-was-Re-Paging-Demo-tp1270p1537.html
Sent from the aerogear-dev mailing list archive at Nabble.com.
More information about the aerogear-dev
mailing list