Difference between revisions of "rest/urls"

From Microformats Wiki
Jump to navigation Jump to search
(new routes)
(method)
Line 1: Line 1:
 
= URL Conventions =
 
= URL Conventions =
  
The recommended conventions for RESTful URLs are those used by [http://topfunky.com/clients/peepcode/REST-cheatsheet.pdf Ruby on Rails]. Note that it is essential to use the proper HTTP verb for the desired action.  Note that the principal unit of operation is the "collection", which typically corresponds to a database table or (in Rails) an ActiveRecord class.
+
The recommended conventions for RESTful URLs are those used by [http://topfunky.com/clients/peepcode/REST-cheatsheet.pdf Ruby on Rails]. Note that it is essential to use the proper HTTP verb for the desired action.  Note that the principal unit of operation is the "collection", which typically corresponds to a database table or (in Rails) an ActiveRecord class. Following these conventions will allow your application to be consumed by ActiveResource, Jester, and other RESTful clients.
  
 
For a collection name "people", the primary routes would be:
 
For a collection name "people", the primary routes would be:
Line 7: Line 7:
 
;GET /people/: return a list of all records
 
;GET /people/: return a list of all records
 
;GET /people/new: return a form for creating a new record
 
;GET /people/new: return a form for creating a new record
;POST /people/: submit a form for creating a new record
+
;POST /people: submit a form for creating a new record
  
 
;GET /people/1: return the first record
 
;GET /people/1: return the first record
Line 13: Line 13:
  
 
;GET /people/1/edit: return a form to edit the first record
 
;GET /people/1/edit: return a form to edit the first record
;POST /people/1: submit a form for editing the first record
+
;PUT /people/1: submit a form for editing the first record

Revision as of 22:25, 27 September 2007

URL Conventions

The recommended conventions for RESTful URLs are those used by Ruby on Rails. Note that it is essential to use the proper HTTP verb for the desired action. Note that the principal unit of operation is the "collection", which typically corresponds to a database table or (in Rails) an ActiveRecord class. Following these conventions will allow your application to be consumed by ActiveResource, Jester, and other RESTful clients.

For a collection name "people", the primary routes would be:

GET /people/
return a list of all records
GET /people/new
return a form for creating a new record
POST /people
submit a form for creating a new record
GET /people/1
return the first record
DELETE /people/1
destroy the first record
GET /people/1/edit
return a form to edit the first record
PUT /people/1
submit a form for editing the first record