Skip to content

Instantly share code, notes, and snippets.

@ksdev-pl
Last active August 29, 2015 14:01
Show Gist options
  • Save ksdev-pl/b4ff45b8d7d41e2fe178 to your computer and use it in GitHub Desktop.
Save ksdev-pl/b4ff45b8d7d41e2fe178 to your computer and use it in GitHub Desktop.
RESTful routes #metodyka
Verb Path Action Route Name
GET /resource index resource.index
GET /resource/create create resource.create
POST /resource store resource.store
GET /resource/{resource} show resource.show
GET /resource/{resource}/edit edit resource.edit
PUT/PATCH /resource/{resource} update resource.update
DELETE /resource/{resource} destroy resource.destroy
HTTP Verb Path Controller#Action Used for
GET /photos photos#index display a list of all photos
GET /photos/new photos#new return an HTML form for creating a new photo
POST /photos photos#create create a new photo
GET /photos/:id photos#show display a specific photo
GET /photos/:id/edit photos#edit return an HTML form for editing a photo
PATCH/PUT /photos/:id photos#update update a specific photo
DELETE /photos/:id photos#destroy delete a specific photo
  • PUT /gists/:id/star
  • /stores?search=near&lat=12.34&lon=-12.34
  • /collection/element/collection?foo=bar&filter=green
  • GET /tickets?sort=-updated_at - Retrieve recently updated tickets
  • GET /tickets?state=closed&sort=-updated_at - Retrieve recently closed tickets
  • GET /tickets?q=return&state=open&sort=-priority,created_at - Retrieve the highest priority open tickets mentioning the word 'return'
  • To make the API experience more pleasant for the average consumer, consider packaging up sets of conditions into easily accessible RESTful paths. For example, the recently closed tickets query above could be packaged up as GET /tickets/recently_closed
  • http://www.vinaysahni.com/best-practices-for-a-pragmatic-restful-api

200: success
201: success (and something has been created)
204: success (and something has been deleted)
400: bad request
401: unauthorized (bad authentication)
403: forbidden (authenticated but not enough permissions)
404: document not found
409: document already exists
500: internal server error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment