[Edit] The story continues with release 0.2: the application goes RESTful. Plus, you can now turn the webmachine TRACE ON/OFF right from your browser. [/Edit]
Kevin Smith from Hypothetical labs has recently stressed the value of the WebMachine. It happened to be not just yet another "cool" stuff, but the real thing.
The best way for me to play with and learn it is to use the real working application. That one happened to be the very nice StickyNotes created by the Hughes Waroquers of BeeBole. Actually, the BeeBole itself has a trailer which looks inspiring and I see where the roots of coolness come from.
The post by Justin Sheehy shows how to integrate the StickyNotes with the original design of the WebMachine. He took the StickyNotes "as-is" and put them under the Webmachine layer.
But the snippets given there which add up to the resource module, do not work with the newest WebMachine releases. They added the wrq module to encapsulate the Request Data manipulation. The calling convention is updated as well.
So, to make it up and go a bit further, I have created a new repository in bitbucket.
It took the StickyNotes client and DB parts "as is" and on the protocol level (as was suggested by Justin):
- separate static pages and dynamic traffic between different resources
- restrict access methods for each resource
- send read requests through GET, not POST (coming soon)
The distribution, when downloaded is ready to launch (use the run.cmd on Windows) . It only needs working Erlang/OTP.
The home page is now a "pure" AJAX web client, allowing to switch GET/POST.... and Content Type and see the results in detail, very much like Curl (not that powerful, but handy).
I left some debug prints on the server to see how the data reflects in the back-end.
The (PUT,Authorization,ETAGS,DELETE) posts of Bryan Fink were extremely helpful to get the concept. Well, POST is not there, but it is here now! And last, but not the least is the the very Justin's screencast, which is was very inspiring for me.