Source

wmexamples / priv / dispatch.conf

Full commit
%% -*- mode: erlang -*-

{[], wmexamples_resource, []}.

%% CouchDB proxy example
%% This will expose all couchdb functionality through webmachine
%% such that requests to
%%   http://localhost:5984/            (default couch host:port)
%% and
%%   http://localhost:8000/couch/      (chosen proxy host:port/path)
%% are equivalent.
%%
%% A few commands to try:
%%   curl http://localhost:8000/couch/
%%   curl -X PUT http://localhost:8000/couch/mytestdb
%%   curl -X PUT http://localhost:8000/couch/mytestdb/123 \
%%        --data "{\"hello\":\"goodbye\"}"
%%   curl http://localhost:8000/couch/mytestdb/123
{["couch",'*'],                   %% expose resource at /couch/*
 couchdb_proxy,                   %% defined in couchdb_proxy.erl
 {"http://localhost:8000/couch/", %% "ExternalPath" init param
  "http://localhost:5984/"}}.     %% "CouchPath" init param


%% Environment Variable Inspection example
%% Try:
%%   curl http://localhost:8000/_env
%%   curl -u webmachine:rules -H "Content-type: application/json" \
%%        -X PUT http://localhost:8000/_env/DEMO --data "\"hello\""
{["_env"],       %% exposed at /_env/
 env_resource,   %% defined in env_resource.erl
 []}.            %% no configuration

{["_env", env],  %% exposed at /_env/VARIABLE_NAME
 env_resource,   %% defined in env_resource.erl
 []}.            %% no configuration