wmexamples /

Filename Size Date modified Message
88 B
91 B
421 B
3.0 KB
133 B
121 B
Title: README for wmexamples
Author: Bryan Fink
Source URL:
Created: 2009.May.18

wmexamples is a demonstration Webmachine application.  It contains a
handful of Webmachine resources that I have posted elsewhere, but have
chosen to assembled here to show off.  To run this application, you'll

- Erlang -
- Webmachine -
- ibrowse -

Note: ibrowse is only needed for the CouchDB proxy resource.  If you
will not be using couchdb_proxy, you can remove the dependency on
ibrowse by commenting out the "ensure_started(ibrowse)" and
"application:stop(ibrowse)" lines in src/wmexamples.erl.


Checkout/unpack wmexamples.

If the directory in which wmexamples lives also contains webmachine
and ibrowse, you should be all set.  If not, you'll need to change the
symlinks in wmexamples/deps to point to where webmachine and ibrowse
are installed.

cd wmexamples

If everything makes fine, run ./ or ./, then point
curl or a browser at http://localhost:8000.  You should get a "Hello,
new world" message back.

Example Resources

The best place to determine what resources are enabled is in
priv/dispatch.conf.  That file describes the dispatch table for this
Webmachine application, and also contains helpful comments.  Other
short descriptions of what examples are included are below.

CouchDB Proxy Resource

couchdb_proxy.erl describe a proxy resource for exposing raw CouchDB
through a webmachine app.  It does very minimal request processing -
only fixing Location headers such that clients of the webmachine
resource direct their requests properly.

To use couchdb_proxy.erl in your own application, copy the file to
your application's src tree, and also make sure the ibrowse is started
before any requests are made to the resource (wmexamples starts
ibrowse at startup in wmexamples.erl).

Environment Variable Resource

env_resource.erl was a sample resource for demonstrating
implementations of several Webmachine resource functions.  The goal of
this resource was to expose the ability to inspect and modify
OS-environment variables.

The story of env_resource's development is available in five blog
posts starting at

Sample Trace Resource

The Webmachine trace utility is available at
http://localhost:8000/wmtrace/ while this application is running.

Four example trace files have been included in the "traces" directory.
They are named example-trace-CODE.wmtrace, where CODE is the HTTP
status code the resource returned at the end of the request.

The sample trace files were generated with the sampletrace_resource,
which is included and exposed at http://localhost:8000/sampletrace
That resource isn't good for much other than generating those simple
examples, but I thought it best to include it for demonstration