couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Sheehy <jus...@iago.org>
Subject Re: Webmachine dispatcher example
Date Thu, 07 May 2009 17:33:00 GMT
I've now changed the dispatcher such that it should be useful outside
of webmachine without affecting internal use.

Check out
http://bitbucket.org/justin/webmachine/src/tip/src/webmachine_dispatcher.erl
if you want to see it.  As with much Erlang, the actual volume of code is
quite small.  It is all Apache2 licensed, so there should be no problem if you
want to use that module in couchdb for this purpose.

The API is quite simple.  Just call webmachine_dispatcher:dispatch/2 with
a path and a list of the dispatch terms I explained in the other
email.  A trivial
example:

1> webmachine_dispatcher:dispatch("/a",[{["a"],some_resource,[]}])
{some_resource,[],[],[],".",[]}

I suspect that you won't have much trouble turning JSON forms into
dispatch terms.

I'm interested to hear how it works out for you, and welcome any suggestions.

Cheers,

-Justin

Mime
View raw message