Default response layout.
I like how praxis lets you define body of the response completely. But I'd like to suggest a "default" response structure like so as an example of its flexibility. Something I implemented in my app which is something required by my JS client consuming API. It showcases flexibility of response, use of kaminari, and ransack for pagination and searching. Compared to grape this tooke me all fo 10 mins to setup, but in grape I head to use 2 extra gems to do that and it was to figure out how they work and to get them to work with my setup.
in dealers controller index action
@q = DCustomer.ransack(params[:q].to_h)
@customers = @q.result().includes(:addresses, :phones).order(params[:order]).page(params[:page]).per(params[:per])
response.body = respond_wtih(params: params, object: @customers)
respond_with returns a hash structure
which in turn results in a json structure like this when I make a request like this
( I searches for all customers that a have a zip code of 60139 in a polymorphic model Address)
{"meta": {"count": 8,"offset": 0,"limit": 10,"currnet_page": 1,"request": {"order": null,"page": null,"per": null,"q": {"addresses_zip_eq": "60139"}}},"payload": [ { "id: 1, "code": "CoolD", "name": "CoolDealer, Global Inc }]}