sunneach / webcandy (http://onerlang.blogspot.com/)
The Hughes Waroquier's StickyNotes app works under control of the WebMachine 1.0+ (implemented on MochiWeb server). A bit deeper attempt to illustrate and use the key mechanisms and methods of this approach.
$ hg clone http://bitbucket.org/sunneach/webcandy/
StickyNotes + WebMachine. Initial merge.
Release 0.1 features
- GET and POST requests are controlled by separate resources, one to serve static files and another one to serve the notes data
- The newest Webmachine stores Dispatch in the priv/dispatch.conf, so to serve static files smoothly the extra routine was added to the supervisor
- The very StickyNotes app was left intact, both the client and the server parts.
- Last, but not least, the home page now is a data exchange client, which allows you to see and control the requests in detail, much like in Curl, but using plain HTML form with Javascript.

Next steps?
- pass the read-only action read_all through the GET. For that the client portion of the StickyNotes needs to be slightly updated.
- add some authentication mechanism to allow different layers of access.
- add ETAG generation and analysis to help prevent concurrent content updates.
- replace the basic "notes" functionality by ... virtually anything
JSON - notes
The priv/dispatch.conf looks like
The first line matches only the access path /notes, the JSON "notes" exchange will go through the "dynamic" channel. Currently, it accepts only POST: the resource src/webmstn_dynamic_resource.erl has only one allowed method:
Static Files: The Supervisor.
the static requestsmatch the second row in the dispatch.conf and will be served by the webmstn_static_resource. The supervisor replaces the atom 'PATHTOWWW' by the actual absolute path to the priv/www in the function prep_dispatch, called by init:
Static Files: The Resource.
The only accepts GET and heads. We are using the default interface in the parametrized module webmachine_resource, so there is no need to write our own version:
Go ahead and try
This revision is from 2009-10-06 13:58
