intridea/grape — pull request #348 by zeroed (2013-02-24 20:37:11+00:00)
Title: paginate - params and header

I wrote this little edit in `lib/grape/endpoint.rb` in order to achieve a basic feature of pagination when grape is managing an `Array` of entries.
It makes just a little bit of 'cut and slice', check some params like `:page` and `:size` and set some headers that can be useful in the MViewC prospective.
There are also a couple of, mandatory, rspec...

I hope someone can find this snippet interesting at least as starting point... but I'm totally looking for some suggestions.
Is this the best, grape-ish, approach to the problem?
Maybe something more complex could be moved and promoted as 'middleware'...

Meanwhile here you can find a simple working example of what this monkeypatching code want to do.
It require the beautiful 'grape-entity'.

https://github.com/zeroed/acinus
https://github.com/zeroed/acinus#paginate-something

`http://localhost:9292/news?page=2&size=3`

Thanks.