RESTful Web API+howto
Basic API
GET / # index. if given name as CGI variable, acts just like GET /name
GET /name # read if exists, "new" form if not GET /name?view=edit # read in specified view if exists, "new" form if not. GET /?view=new # new card form POST / POST /name # create new card PUT / PUT /name # update card DELETE / DELETE /name # delete card (move to trash)
Variants
Names
Cards can be identified in three ways:
- name - default
- codename - begins with ":"
- id - begins with "~"
Names can be given in CGI params or in path. Error if 2 different names are given. Note that if a nonexistent codename or id is given in a normal GET request, response is 404 (not "new")
Formats
You can add ".<format extension>" to the end of any requests to specify the response file formats.
CGI Variables
Including:
- view args - eg layout, view, item, size, keyword
- action args - (not sure what those are yet)
- model args for PUTS and POSTS - eg name, type, content
Currently those model args come as card[name], card[type], etc. We need to decide if that is still valuable (for example, in separating them from view/action args and how to specify nested cards, which will probably be some variant on that pseudo-hash structure.
GET Variants
POST /name -> GET /create/name PUT /name -> GET /update/name
DELETE /name -> GET /delete/name
# and, for consistency...
GET /name -> GET /read/name