Many people have asked for an example Webmachine resource that responds to POST. If you follow my twitter feed, you may have caught this gem.
I figured that example could use a little fleshing out, so I’ve added a resource to my wmexamples repo.
formjson_resourc.erl makes an attempt at demonstrating the simplest way to handle a POST, while also demonstrating the difference between content-producing functions (to_json/2 in this example, and others named in content_types_provided/2), which put content in the response body simply by returning it, and other functions, which have to put content in the response body by returning a modified ReqData.
For another example of handling POST, read demo_fs_resource.erl that comes with Webmachine. It implements post_is_create/2, create_path/2, content_types_accepted/2, and accept_content/2 to handle POST requests. (Incidentally, demo_fs_resource is a good example of many Webmachine resource functions.)
Updated to include content_types_accepted/2 in the list of functions handling POST requests – thanks for catching it, Lou!