Friday, July 24, 2009

Routing in Bombay (WIP)

Default routes

Here are some examples that illustrate the default routes I came up with:

Example Request handler function
GET / _home()
GET /foo _show()
GET /foo?baz=qux _query()
PUT /bar _save()
DELETE /bar _delete()
POST / _post()
POST /login _login()
GET /users/ users_home()
GET /users/1 users_show()
GET /users/1?baz=qux users_query()
PUT /users/2 users_save()
DELETE /users/2 users_delete()
POST /users/ users_post()
POST /users/poke users_poke()

I chose *_save because it captures both the CREATE and UPDATE semantics of PUT. The other option was *_write() requiring me to use *_read instead of *_show for symmetry but that didn't feel right.

*_query was chosen over *_search and *_filter because its asking semantics is generic enough to be used in many different situation than the locating and removing semantics of the alternatives.


If none of the above handler functions are found, mapper.lib will fall back on the catchall handler functions.

Request fall-back-1 fall-back-2
* /users/1 users_catchall() _catchall()
* /foo _catchall()

Update July 27, 2009: Renamed Swx to Bombay

No comments: