Resting Pug logo Resting Pug

Description

Shows a list of subjects.
You can filter subjects by attributes using filter param.
You can sort subjects using sort param. It is a string of comma-separated attributes with minus before attributes you wants to sort descending.
You can paginate subjcts with page and per_page params.

Example

Request:
GET http://your.awesome/api/books
GET http://your.awesome/api/books?filter[author]="King"
GET http://your.awesome/api/books?filter[author][]="King"&filter[author][]="Kesey"
GET http://your.awesome/api/books?sort=-id,name,-author
GET http://your.awesome/api/books?page=3&per_page=10
GET http://your.awesome/api/books?filter[author]="King"&sort=-id?page=3&per_page=10

Response:
200 OK
{
  "books": [{
    "id": 2,
    "name": "The Green Mile",
    "author": "Stephen King"
  }, {
    "id": 1,
    "name": "11/22/63",
    "author": "Stephen King"
  }]
}

How to customize

Use

Source code

# lib/resting_pug/actions.rb

def index
  run_chain(index_chain)
end
Find me on GitHub