anchor.diff:  %% This module is open source and available under the terms of the MIT
   %% license.
   %% 
  -%% Data = erlang:iolist_to_binary([
  +%% The protocol buffers message used to represent a dynmoite mesage is fairly
  +%% simple:
  +%% 
  +%% message Dynomite_Message {
  +%%     required string key = 1;
  +%%     required bytes context = 2;
  +%%     required bytes value = 3;
  +%% }
  +%% 
  +%% The following is an example use of this interface.
  +%% 
  +%% 1> Data = erlang:iolist_to_binary([
   %%     protobuffs:encode(1, "foo", string),
   %%     protobuffs:encode(2, erlang:term_to_binary([1]), bytes),
   %%     protobuffs:encode(3, <<"hello world">>, bytes)
  -%% ]),
  -%% http:request(put, {"http://127.0.0.1:9300/", [], "application/x-protobuffs", Data}, [], []),
  -%% http:request(get, {"http://127.0.0.1:9300/foo", []}, [], []).
  +%% ]).
  +%% 2> http:request(put, {"http://127.0.0.1:9300/", [], "application/x-protobuffs", Data}, [], []).
  +%% 3> http:request(get, {"http://127.0.0.1:9300/foo", []}, [], []).
   %% 
   -module(dynomite_pb).
   -author('Nick Gerakines <nick@gerakines.net>').
   -export([start_link/0, stop/0, dispatch/1]).
   -include("config.hrl").
   
  +%% @doc Attempts to start the protocol buffers interface. This is dependant on
  +%% the #config.pb_port record field being set.
   start_link() ->
  -  Config = configuration:get_config(),
  -  case Config#config.pb_port of
  -    undefined -> dummy_server:start_link(?MODULE);
  -    Port -> mochiweb_http:start([{name, ?MODULE}, {loop, fun dispatch/1}, {port, Port}])
  -  end.
  +    Config = configuration:get_config(),
  +    case Config#config.pb_port of
  +        undefined ->
  +            dummy_server:start_link(?MODULE);
  +        Port ->
  +            mochiweb_http:start([{name, ?MODULE}, {loop, fun dispatch/1}, {port, Port}])
  +    end.
   
  +%% @doc Attempts to stop the protocol buffers interface.
   stop() ->
  -    mochiweb_http:stop(?MODULE).
  +    catch mochiweb_http:stop(?MODULE).
   
  +%% @doc Process requests as dispatched by the MochiWeb application. Request
  +%% processing is based on the HTTP method and URI as per mochiweb_request:get(method)
  +%% and mochiweb_request:get(path) function calls. The GET, PUT, HEAD and DELETE
  +%% HTTP methods are supported and map to the retrieval, creation, existance
  +%% checking and removal of key/value pairs within Dynomite.
  +%% 
  +%% The GET, HEAD and DELETE request types all use the URI to indicate the key
  +%% that the request is associated with. In all cases, the key is considered
  +%% any characters after the root "/" of the URI. For example, the URI "/foobar"
  +%% indicates that the key is "foobar".
  +%% 
  +%% In PUT requests, the uri is simple "/" and the key is contained in the
  +%% protocol buffers encoded body.
   dispatch(Req) ->
       case [Req:get(method), Req:get(path)] of
           ['GET', "/" ++ Key] ->
  
positive.code: %% Copyright (c) 2008-2009 Nick Gerakines <nick@gerakines.net>
  %% 
  %% Permission is hereby granted, free of charge, to any person
  %% obtaining a copy of this software and associated documentation
  
negative.code: %% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  %% OTHER DEALINGS IN THE SOFTWARE.
  %% 
  %% @author Nick Gerakines <nick@gerakines.net> [http://socklabs.com/]
  %% @doc A RESTful Protocol Buffers interface using MochiWeb. This interface 
  %% provides very basic CRUD functionality by exposing the GET, PUT, HEAD and
  