Commits

Anonymous committed 3226e5f

Webmachine moved a long time ago. Removing the vestiges.

Comments (0)

Files changed (97)

Emakefile

-% -*- mode: erlang -*-
-{["src/*"], 
- [{i, "include"},
-  {outdir, "ebin"},
-  debug_info]
-}.

LICENSE

-
-                                 Apache License
-                           Version 2.0, January 2004
-                        http://www.apache.org/licenses/
-
-   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
-   1. Definitions.
-
-      "License" shall mean the terms and conditions for use, reproduction,
-      and distribution as defined by Sections 1 through 9 of this document.
-
-      "Licensor" shall mean the copyright owner or entity authorized by
-      the copyright owner that is granting the License.
-
-      "Legal Entity" shall mean the union of the acting entity and all
-      other entities that control, are controlled by, or are under common
-      control with that entity. For the purposes of this definition,
-      "control" means (i) the power, direct or indirect, to cause the
-      direction or management of such entity, whether by contract or
-      otherwise, or (ii) ownership of fifty percent (50%) or more of the
-      outstanding shares, or (iii) beneficial ownership of such entity.
-
-      "You" (or "Your") shall mean an individual or Legal Entity
-      exercising permissions granted by this License.
-
-      "Source" form shall mean the preferred form for making modifications,
-      including but not limited to software source code, documentation
-      source, and configuration files.
-
-      "Object" form shall mean any form resulting from mechanical
-      transformation or translation of a Source form, including but
-      not limited to compiled object code, generated documentation,
-      and conversions to other media types.
-
-      "Work" shall mean the work of authorship, whether in Source or
-      Object form, made available under the License, as indicated by a
-      copyright notice that is included in or attached to the work
-      (an example is provided in the Appendix below).
-
-      "Derivative Works" shall mean any work, whether in Source or Object
-      form, that is based on (or derived from) the Work and for which the
-      editorial revisions, annotations, elaborations, or other modifications
-      represent, as a whole, an original work of authorship. For the purposes
-      of this License, Derivative Works shall not include works that remain
-      separable from, or merely link (or bind by name) to the interfaces of,
-      the Work and Derivative Works thereof.
-
-      "Contribution" shall mean any work of authorship, including
-      the original version of the Work and any modifications or additions
-      to that Work or Derivative Works thereof, that is intentionally
-      submitted to Licensor for inclusion in the Work by the copyright owner
-      or by an individual or Legal Entity authorized to submit on behalf of
-      the copyright owner. For the purposes of this definition, "submitted"
-      means any form of electronic, verbal, or written communication sent
-      to the Licensor or its representatives, including but not limited to
-      communication on electronic mailing lists, source code control systems,
-      and issue tracking systems that are managed by, or on behalf of, the
-      Licensor for the purpose of discussing and improving the Work, but
-      excluding communication that is conspicuously marked or otherwise
-      designated in writing by the copyright owner as "Not a Contribution."
-
-      "Contributor" shall mean Licensor and any individual or Legal Entity
-      on behalf of whom a Contribution has been received by Licensor and
-      subsequently incorporated within the Work.
-
-   2. Grant of Copyright License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      copyright license to reproduce, prepare Derivative Works of,
-      publicly display, publicly perform, sublicense, and distribute the
-      Work and such Derivative Works in Source or Object form.
-
-   3. Grant of Patent License. Subject to the terms and conditions of
-      this License, each Contributor hereby grants to You a perpetual,
-      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
-      (except as stated in this section) patent license to make, have made,
-      use, offer to sell, sell, import, and otherwise transfer the Work,
-      where such license applies only to those patent claims licensable
-      by such Contributor that are necessarily infringed by their
-      Contribution(s) alone or by combination of their Contribution(s)
-      with the Work to which such Contribution(s) was submitted. If You
-      institute patent litigation against any entity (including a
-      cross-claim or counterclaim in a lawsuit) alleging that the Work
-      or a Contribution incorporated within the Work constitutes direct
-      or contributory patent infringement, then any patent licenses
-      granted to You under this License for that Work shall terminate
-      as of the date such litigation is filed.
-
-   4. Redistribution. You may reproduce and distribute copies of the
-      Work or Derivative Works thereof in any medium, with or without
-      modifications, and in Source or Object form, provided that You
-      meet the following conditions:
-
-      (a) You must give any other recipients of the Work or
-          Derivative Works a copy of this License; and
-
-      (b) You must cause any modified files to carry prominent notices
-          stating that You changed the files; and
-
-      (c) You must retain, in the Source form of any Derivative Works
-          that You distribute, all copyright, patent, trademark, and
-          attribution notices from the Source form of the Work,
-          excluding those notices that do not pertain to any part of
-          the Derivative Works; and
-
-      (d) If the Work includes a "NOTICE" text file as part of its
-          distribution, then any Derivative Works that You distribute must
-          include a readable copy of the attribution notices contained
-          within such NOTICE file, excluding those notices that do not
-          pertain to any part of the Derivative Works, in at least one
-          of the following places: within a NOTICE text file distributed
-          as part of the Derivative Works; within the Source form or
-          documentation, if provided along with the Derivative Works; or,
-          within a display generated by the Derivative Works, if and
-          wherever such third-party notices normally appear. The contents
-          of the NOTICE file are for informational purposes only and
-          do not modify the License. You may add Your own attribution
-          notices within Derivative Works that You distribute, alongside
-          or as an addendum to the NOTICE text from the Work, provided
-          that such additional attribution notices cannot be construed
-          as modifying the License.
-
-      You may add Your own copyright statement to Your modifications and
-      may provide additional or different license terms and conditions
-      for use, reproduction, or distribution of Your modifications, or
-      for any such Derivative Works as a whole, provided Your use,
-      reproduction, and distribution of the Work otherwise complies with
-      the conditions stated in this License.
-
-   5. Submission of Contributions. Unless You explicitly state otherwise,
-      any Contribution intentionally submitted for inclusion in the Work
-      by You to the Licensor shall be under the terms and conditions of
-      this License, without any additional terms or conditions.
-      Notwithstanding the above, nothing herein shall supersede or modify
-      the terms of any separate license agreement you may have executed
-      with Licensor regarding such Contributions.
-
-   6. Trademarks. This License does not grant permission to use the trade
-      names, trademarks, service marks, or product names of the Licensor,
-      except as required for reasonable and customary use in describing the
-      origin of the Work and reproducing the content of the NOTICE file.
-
-   7. Disclaimer of Warranty. Unless required by applicable law or
-      agreed to in writing, Licensor provides the Work (and each
-      Contributor provides its Contributions) on an "AS IS" BASIS,
-      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
-      implied, including, without limitation, any warranties or conditions
-      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
-      PARTICULAR PURPOSE. You are solely responsible for determining the
-      appropriateness of using or redistributing the Work and assume any
-      risks associated with Your exercise of permissions under this License.
-
-   8. Limitation of Liability. In no event and under no legal theory,
-      whether in tort (including negligence), contract, or otherwise,
-      unless required by applicable law (such as deliberate and grossly
-      negligent acts) or agreed to in writing, shall any Contributor be
-      liable to You for damages, including any direct, indirect, special,
-      incidental, or consequential damages of any character arising as a
-      result of this License or out of the use or inability to use the
-      Work (including but not limited to damages for loss of goodwill,
-      work stoppage, computer failure or malfunction, or any and all
-      other commercial damages or losses), even if such Contributor
-      has been advised of the possibility of such damages.
-
-   9. Accepting Warranty or Additional Liability. While redistributing
-      the Work or Derivative Works thereof, You may choose to offer,
-      and charge a fee for, acceptance of support, warranty, indemnity,
-      or other liability obligations and/or rights consistent with this
-      License. However, in accepting such obligations, You may act only
-      on Your own behalf and on Your sole responsibility, not on behalf
-      of any other Contributor, and only if You agree to indemnify,
-      defend, and hold each Contributor harmless for any liability
-      incurred by, or claims asserted against, such Contributor by reason
-      of your accepting any such warranty or additional liability.
-
-   END OF TERMS AND CONDITIONS
-

Makefile

-ERL          ?= erl
-APP          := webmachine
-
-.PHONY: deps
-
-all: deps
-	@(./rebar compile)
-
-deps:
-	@(./rebar get-deps)
-
-clean:
-	@(./rebar clean)
-
-distclean: clean
-	@(./rebar delete-deps)
-
-edoc:
-	@$(ERL) -noshell -run edoc_run application '$(APP)' '"."' '[{preprocess, true},{includes, ["."]}]'
-
-test: all
-	scripts/run_tests.escript ebin | tee test.log
-
+
+Webmachine has moved to http://webmachine.basho.com/
+

THANKS

-The following people have contributed to Webmachine:
-
-Andy Gross
-Justin Sheehy
-John Muellerleile
-Robert Ahrens
-Jeremy Latt
-Bryan Fink
-Ryan Tilder
-Taavi Talvik
-Marc Worrell
-Seth Falcon
-Tuncer Ayaz
-Martin Scholl
-Paul Mineiro
-Dave Smith
-Arjan Scherpenisse
-

demo/Makefile

-ERL ?= erl
-APP := webmachine_demo
-
-all:
-	@../rebar compile
-
-clean:
-	@../rebar clean
-
-docs:
-	@erl -noshell -run edoc_run application '$(APP)' '"."' '[]'

demo/README

-Project Skeleton for the webmachine_demo app.
-
-You should find in this directory:
-
-README : this file
-Makefile : simple make commands
-rebar : the Rebar build tool for Erlang applications
-rebar.config : configuration for Rebar
-start.sh : simple startup script for running webmachine_demo
-start-debug.sh : run webmachine_demo in "debug" mode (automatic module
-                 reloading on compilation)
-/ebin
-  /webmachine_demo.app : the Erlang app specification
-/src
-  /webmachine_demo_app.erl : base module for the Erlang application
-  /webmachine_demo_sup.erl : OTP supervisor for the application
-  /webmachine_demo_resource.erl : a simple example Webmachine resource
-/priv
-  /dispatch.conf : the Webmachine URL-dispatching table
-  /www : a convenient place to put your static web content
-
-You probably want to do one of a couple of things at this point:
-
-0. Build the skeleton application:
-   $ make
-   - or -
-   $ ./rebar compile
-
-1. Start up the skeleton application:
-   $ ./start.sh
-
-2. Change the basic application:
-   edit src/webmachine_demo_resource.erl
-
-3. Add some new resources:
-   edit src/YOUR_NEW_RESOURCE.erl
-   edit priv/dispatch.conf

demo/ebin/webmachine_demo.app

-{application, webmachine_demo,
- [{description, "webmachine_demo"},
-  {vsn, "0.1"},
-  {modules, [
-	     webmachine_demo,
-	     webmachine_demo_app,
-	     webmachine_demo_sup,
-	     webmachine_demo_resource,
-	     demo_fs_resource
-	    ]},
-  {registered, []},
-  {mod, {webmachine_demo_app, []}},
-  {env, []},
-  {applications, [kernel, stdlib, crypto]}]}.

demo/priv/dispatch.conf

-%%-*- mode: erlang -*-
-{["demo", '*'], webmachine_demo_resource, []}.
-{["fs", '*'], demo_fs_resource, [{root, "/tmp/fs"}]}.

demo/rebar.config

-%%-*- mode: erlang -*-
-{deps, [{webmachine, "1\.6", {hg, "http://bitbucket.org/basho/webmachine", "tip"}}]}.
-

demo/src/demo_fs_resource.erl

-%% @author Bryan Fink <bryan@basho.com>
-%% @author Andy Gross <andy@basho.com>
-%% @author Justin Sheehy <justin@basho.com>
-%% @copyright 2008-2009 Basho Technologies, Inc.
-
--module(demo_fs_resource).
--export([init/1]).
--export([allowed_methods/2,
-	 resource_exists/2,
-	 last_modified/2,
-	 content_types_provided/2,
-	 content_types_accepted/2,
-         delete_resource/2,
-         post_is_create/2,
-         create_path/2,
-	 provide_content/2,
-	 accept_content/2,
-	 generate_etag/2]).
-
--record(context, {root,response_body=undefined,metadata=[]}).
-
--include_lib("kernel/include/file.hrl").
--include_lib("webmachine/include/webmachine.hrl").
-
-init(ConfigProps) ->
-    {root, Root} = proplists:lookup(root, ConfigProps),
-    {ok, #context{root=Root}}.
-    
-allowed_methods(ReqData, Context) ->
-    {['HEAD', 'GET', 'PUT', 'DELETE', 'POST'], ReqData, Context}.
-
-file_path(Context, Name) ->
-    RelName = case hd(Name) of
-        "/" -> tl(Name);
-        _ -> Name
-    end,
-    filename:join([Context#context.root, RelName]).
-
-file_exists(Context, Name) ->
-    NamePath = file_path(Context, Name),
-    case filelib:is_regular(NamePath) of 
-	true ->
-	    {true, NamePath};
-	false ->
-	    false
-    end.
-
-resource_exists(ReqData, Context) ->
-    Path = wrq:disp_path(ReqData),
-    case file_exists(Context, Path) of 
-	{true, _} ->
-	    {true, ReqData, Context};
-	_ ->
-            case Path of
-                "p" -> {true, ReqData, Context};
-                _ -> {false, ReqData, Context}
-            end
-    end.
-
-maybe_fetch_object(Context, Path) ->
-    % if returns {true, NewContext} then NewContext has response_body
-    case Context#context.response_body of
-	undefined ->
-	    case file_exists(Context, Path) of 
-		{true, FullPath} ->
-		    {ok, Value} = file:read_file(FullPath),
-		    {true, Context#context{response_body=Value}};
-		false ->
-		    {false, Context}
-	    end;
-	_Body ->
-	    {true, Context}
-    end.
-
-content_types_provided(ReqData, Context) ->
-    CT = webmachine_util:guess_mime(wrq:disp_path(ReqData)),
-    {[{CT, provide_content}], ReqData,
-     Context#context{metadata=[{'content-type', CT}|Context#context.metadata]}}.
-
-content_types_accepted(ReqData, Context) ->
-    CT = case wrq:get_req_header("content-type", ReqData) of
-             undefined -> "application/octet-stream";
-             X -> X
-         end,
-    {MT, _Params} = webmachine_util:media_type_to_detail(CT),
-    {[{MT, accept_content}], ReqData,
-     Context#context{metadata=[{'content-type', MT}|Context#context.metadata]}}.
-
-accept_content(ReqData, Context) ->
-    Path = wrq:disp_path(ReqData),
-    FP = file_path(Context, Path),
-    ok = filelib:ensure_dir(filename:dirname(FP)),
-    ReqData1 = case file_exists(Context, Path) of 
-	{true, _} ->
-            ReqData;
-	_ ->
-            LOC = "http://" ++
-                   wrq:get_req_header("host", ReqData) ++
-                   "/fs/" ++ Path,
-            wrq:set_resp_header("Location", LOC, ReqData)
-    end,
-    Value = wrq:req_body(ReqData1),
-    case file:write_file(FP, Value) of
-        ok ->
-            {true, wrq:set_resp_body(Value, ReqData1), Context};
-        Err ->
-            {{error, Err}, ReqData1, Context}
-    end.    
-
-post_is_create(ReqData, Context) ->
-    {true, ReqData, Context}.
-
-create_path(ReqData, Context) ->
-    case wrq:get_req_header("slug", ReqData) of
-        undefined -> {undefined, ReqData, Context};
-        Slug ->
-            case file_exists(Context, Slug) of
-                {true, _} -> {undefined, ReqData, Context};
-                _ -> {Slug, ReqData, Context}
-            end
-    end.
-
-delete_resource(ReqData, Context) ->
-    case file:delete(file_path(
-                       Context, wrq:disp_path(ReqData))) of
-        ok -> {true, ReqData, Context};
-        _ -> {false, ReqData, Context}
-    end.
-
-provide_content(ReqData, Context) ->
-    case maybe_fetch_object(Context, wrq:disp_path(ReqData)) of 
-	{true, NewContext} ->
-	    Body = NewContext#context.response_body,
-	    {Body, ReqData, Context};
-	{false, NewContext} ->
-	    {error, ReqData, NewContext}
-    end.
-
-last_modified(ReqData, Context) ->
-    {true, FullPath} = file_exists(Context,
-                                   wrq:disp_path(ReqData)),
-    LMod = filelib:last_modified(FullPath),
-    {LMod, ReqData, Context#context{metadata=[{'last-modified',
-                    httpd_util:rfc1123_date(LMod)}|Context#context.metadata]}}.
-
-hash_body(Body) -> mochihex:to_hex(binary_to_list(crypto:sha(Body))).
-
-generate_etag(ReqData, Context) ->
-    case maybe_fetch_object(Context, wrq:disp_path(ReqData)) of
-        {true, BodyContext} ->
-            ETag = hash_body(BodyContext#context.response_body),
-            {ETag, ReqData,
-             BodyContext#context{metadata=[{etag,ETag}|
-                                           BodyContext#context.metadata]}};
-        _ ->
-            {undefined, ReqData, Context}
-    end.

demo/src/webmachine_demo.erl

--module(webmachine_demo).
--author('Andy Gross <andy@basho.com>').
--author('Justin Sheehy <justin@@basho.com>').
--export([start/0, stop/0]).
-
-ensure_started(App) ->
-    case application:start(App) of
-	ok ->
-	    ok;
-	{error, {already_started, App}} ->
-	    ok
-    end.
-	
-%% @spec start() -> ok
-%% @doc Start the webmachine_demo server.
-start() ->
-    ensure_started(crypto),
-    ensure_started(webmachine),
-    application:start(webmachine_demo).
-
-%% @spec stop() -> ok
-%% @doc Stop the webmachine_demo server.
-stop() ->
-    Res = application:stop(webmachine_demo),
-    application:stop(webmachine),
-    application:stop(crypto),
-    Res.

demo/src/webmachine_demo_app.erl

-%% @author Andy Gross <andy@basho.com>
-%% @author Justin Sheehy <justin@basho.com>
-
-%% @doc Callbacks for the webmachine_demo application.
-
--module(webmachine_demo_app).
-
--behaviour(application).
--export([start/2,stop/1]).
-
-
-%% @spec start(_Type, _StartArgs) -> ServerRet
-%% @doc application start callback for webmachine_demo.
-start(_Type, _StartArgs) ->
-    webmachine_demo_sup:start_link().
-
-%% @spec stop(_State) -> ServerRet
-%% @doc application stop callback for webmachine_demo.
-stop(_State) ->
-    ok.

demo/src/webmachine_demo_resource.erl

-%% @author Justin Sheehy <justin@basho.com>
-%% @copyright 2007-2009 Basho Technologies, Inc.  All Rights Reserved.
-%% @doc Example webmachine_resource.
-
--module(webmachine_demo_resource).
--author('Justin Sheehy <justin@basho.com>').
--export([init/1, to_html/2, to_text/2, content_types_provided/2,
-         is_authorized/2, generate_etag/2, expires/2]).
-
--include_lib("webmachine/include/webmachine.hrl").
-
-init([]) -> {ok, undefined}.
-    
-content_types_provided(ReqData, Context) ->
-    {[{"text/html", to_html},{"text/plain",to_text}], ReqData, Context}.
-
-to_text(ReqData, Context) ->
-    Path = wrq:disp_path(ReqData),
-    Body = io_lib:format("Hello ~s from webmachine.~n", [Path]),
-    {Body, ReqData, Context}.
-
-to_html(ReqData, Context) ->
-    {Body, _RD, Ctx2} = to_text(ReqData, Context),
-    HBody = io_lib:format("<html><body>~s</body></html>~n",
-                          [erlang:iolist_to_binary(Body)]),
-    {HBody, ReqData, Ctx2}.
-
-is_authorized(ReqData, Context) ->
-    case wrq:disp_path(ReqData) of
-        "authdemo" -> 
-            case wrq:get_req_header("authorization", ReqData) of
-                "Basic "++Base64 ->
-                    Str = base64:mime_decode_to_string(Base64),
-                    case string:tokens(Str, ":") of
-                        ["authdemo", "demo1"] ->
-                            {true, ReqData, Context};
-                        _ ->
-                            {"Basic realm=webmachine", ReqData, Context}
-                    end;
-                _ ->
-                    {"Basic realm=webmachine", ReqData, Context}
-            end;
-        _ -> {true, ReqData, Context}
-    end.
-
-expires(ReqData, Context) -> {{{2021,1,1},{0,0,0}}, ReqData, Context}.
-
-generate_etag(ReqData, Context) -> {wrq:raw_path(ReqData), ReqData, Context}.
-

demo/src/webmachine_demo_sup.erl

-%% @author author <author@example.com>
-%% @copyright YYYY author.
-
-%% @doc Supervisor for the webmachine_demo application.
-
--module(webmachine_demo_sup).
--author('author <author@example.com>').
-
--behaviour(supervisor).
-
-%% External exports
--export([start_link/0, upgrade/0]).
-
-%% supervisor callbacks
--export([init/1]).
-
-%% @spec start_link() -> ServerRet
-%% @doc API for starting the supervisor.
-start_link() ->
-    supervisor:start_link({local, ?MODULE}, ?MODULE, []).
-
-%% @spec upgrade() -> ok
-%% @doc Add processes if necessary.
-upgrade() ->
-    {ok, {_, Specs}} = init([]),
-
-    Old = sets:from_list(
-	    [Name || {Name, _, _, _} <- supervisor:which_children(?MODULE)]),
-    New = sets:from_list([Name || {Name, _, _, _, _, _} <- Specs]),
-    Kill = sets:subtract(Old, New),
-
-    sets:fold(fun (Id, ok) ->
-		      supervisor:terminate_child(?MODULE, Id),
-		      supervisor:delete_child(?MODULE, Id),
-		      ok
-	      end, ok, Kill),
-
-    [supervisor:start_child(?MODULE, Spec) || Spec <- Specs],
-    ok.
-
-%% @spec init([]) -> SupervisorTree
-%% @doc supervisor callback.
-init([]) ->
-    Ip = case os:getenv("WEBMACHINE_IP") of false -> "0.0.0.0"; Any -> Any end,
-    {ok, Dispatch} = file:consult(filename:join(
-                         [filename:dirname(code:which(?MODULE)),
-                          "..", "priv", "dispatch.conf"])),
-    WebConfig = [
-		 {ip, Ip},
-                 {backlog, 1000},
-		 {port, 8000},
-                 {log_dir, "priv/log"},
-		 {dispatch, Dispatch}],
-    Web = {webmachine_mochiweb,
-	   {webmachine_mochiweb, start, [WebConfig]},
-	   permanent, 5000, worker, dynamic},
-    Processes = [Web],
-    {ok, { {one_for_one, 10, 10}, Processes} }.

demo/start.sh

-#!/bin/sh
-cd `dirname $0`
-exec erl -pa $PWD/ebin $PWD/deps/webmachine/ebin $PWD/deps/webmachine/deps/mochiweb/ebin -boot start_sasl -s reloader -s webmachine_demo
Add a comment to this file

docs/http-headers-status-v3.png

Removed
Old image
Add a comment to this file

ebin/.hg_empty_dir

Empty file removed.

ebin/webmachine.app

-{application, webmachine,
- [{description, "webmachine"},
-  {vsn, "1.7.0"},
-  {modules, [
-    webmachine,
-    webmachine_app,
-    webmachine_decision_core,
-    webmachine_deps,
-    webmachine_dispatcher,
-    webmachine_error_handler,
-    webmachine_logger,
-    webmachine_perf_logger,
-    webmachine_resource,
-    webmachine_request,
-    webmachine_router,
-    webmachine_sup,
-    webmachine_mochiweb,
-    webmachine_multipart,
-    webmachine_util,
-    wrq,
-    wmtrace_resource
-  ]},
-  {registered, []},
-  {mod, {webmachine_app, []}},
-  {env, [
-         {dispatch_list, []}
-        ]},
-  {applications, [kernel, stdlib, crypto]}]}.

include/webmachine.hrl

--export([ping/2]).
-
--include_lib("webmachine/include/wm_reqdata.hrl").
-
-ping(ReqData, State) ->
-    {pong, ReqData, State}.
-
-

include/wm_reqdata.hrl

--record(wm_reqdata, {method, version, peer, wm_state,
-                     disp_path, path, raw_path, path_info, path_tokens,
-                     app_root,response_code,max_recv_body, max_recv_hunk,
-                     req_cookie, req_qs, req_headers, req_body,
-                     resp_redirect, resp_headers, resp_body,
-                     host_tokens, port
-                    }).
-

include/wm_reqstate.hrl

--record(wm_reqstate, {socket=undefined,
-                   metadata=dict:new(),
-                   range=undefined,
-                   peer=undefined,
-                   reqdata=undefined,
-                   bodyfetch=undefined,
-                   reqbody=undefined,
-                   log_data=undefined
-                  }).
-

priv/templates/Makefile

-ERL ?= erl
-APP := {{appid}}
-
-.PHONY: deps
-
-all: deps
-	@./rebar compile
-
-deps:
-	@./rebar get-deps
-
-clean:
-	@./rebar clean
-
-distclean: clean
-	@./rebar delete-deps
-
-docs:
-	@erl -noshell -run edoc_run application '$(APP)' '"."' '[]'

priv/templates/README

-Project Skeleton for the {{appid}} app.
-
-You should find in this directory:
-
-README : this file
-Makefile : simple make commands
-rebar : the Rebar build tool for Erlang applications
-rebar.config : configuration for Rebar
-start.sh : simple startup script for running {{appid}}
-/ebin
-  /{{appid}}.app : the Erlang app specification
-/src
-  /{{appid}}_app.erl : base module for the Erlang application
-  /{{appid}}_sup.erl : OTP supervisor for the application
-  /{{appid}}_resource.erl : a simple example Webmachine resource
-/priv
-  /dispatch.conf : the Webmachine URL-dispatching table
-  /www : a convenient place to put your static web content
-
-You probably want to do one of a couple of things at this point:
-
-0. Build the skeleton application:
-   $ make
-   - or -
-   $ ./rebar compile
-
-1. Start up the skeleton application:
-   $ ./start.sh
-
-2. Change the basic application:
-   edit src/{{appid}}_resource.erl
-
-3. Add some new resources:
-   edit src/YOUR_NEW_RESOURCE.erl
-   edit priv/dispatch.conf

priv/templates/ebin/wmskel.app

-%%-*- mode: erlang -*-
-{application, {{appid}},
- [
-  {description, "{{appid}}"},
-  {vsn, "1"},
-  {modules, [
-             {{appid}},
-             {{appid}}_app,
-             {{appid}}_sup,
-             {{appid}}_resource
-            ]},
-  {registered, []},
-  {applications, [
-                  kernel,
-                  stdlib,
-                  crypto,
-                  mochiweb,
-                  webmachine
-                 ]},
-  {mod, { {{appid}}_app, []}},
-  {env, []}
- ]}.

priv/templates/priv/dispatch.conf

-%%-*- mode: erlang -*-
-{[], {{appid}}_resource, []}.

priv/templates/rebar.config

-%%-*- mode: erlang -*-
-{deps, [{webmachine, "1\\.6", {hg, "http://bitbucket.org/basho/webmachine", "tip"}}]}.
-

priv/templates/src/wmskel.erl

-%% @author author <author@example.com>
-%% @copyright YYYY author.
-
-%% @doc {{appid}} startup code
-
--module({{appid}}).
--author('author <author@example.com>').
--export([start/0, start_link/0, stop/0]).
-
-ensure_started(App) ->
-    case application:start(App) of
-	ok ->
-	    ok;
-	{error, {already_started, App}} ->
-	    ok
-    end.
-
-%% @spec start_link() -> {ok,Pid::pid()}
-%% @doc Starts the app for inclusion in a supervisor tree
-start_link() ->
-    ensure_started(crypto),
-    ensure_started(mochiweb),
-    application:set_env(webmachine, webmachine_logger_module, 
-                        webmachine_logger),
-    ensure_started(webmachine),
-    {{appid}}_sup:start_link().
-
-%% @spec start() -> ok
-%% @doc Start the {{appid}} server.
-start() ->
-    ensure_started(crypto),
-    ensure_started(mochiweb),
-    application:set_env(webmachine, webmachine_logger_module, 
-                        webmachine_logger),
-    ensure_started(webmachine),
-    application:start({{appid}}).
-
-%% @spec stop() -> ok
-%% @doc Stop the {{appid}} server.
-stop() ->
-    Res = application:stop({{appid}}),
-    application:stop(webmachine),
-    application:stop(mochiweb),
-    application:stop(crypto),
-    Res.

priv/templates/src/wmskel_app.erl

-%% @author author <author@example.com>
-%% @copyright YYYY author.
-
-%% @doc Callbacks for the {{appid}} application.
-
--module({{appid}}_app).
--author('author <author@example.com>').
-
--behaviour(application).
--export([start/2,stop/1]).
-
-
-%% @spec start(_Type, _StartArgs) -> ServerRet
-%% @doc application start callback for {{appid}}.
-start(_Type, _StartArgs) ->
-    {{appid}}_sup:start_link().
-
-%% @spec stop(_State) -> ServerRet
-%% @doc application stop callback for {{appid}}.
-stop(_State) ->
-    ok.

priv/templates/src/wmskel_resource.erl

-%% @author author <author@example.com>
-%% @copyright YYYY author.
-%% @doc Example webmachine_resource.
-
--module({{appid}}_resource).
--export([init/1, to_html/2]).
-
--include_lib("webmachine/include/webmachine.hrl").
-
-init([]) -> {ok, undefined}.
-
-to_html(ReqData, State) ->
-    {"<html><body>Hello, new world</body></html>", ReqData, State}.

priv/templates/src/wmskel_sup.erl

-%% @author author <author@example.com>
-%% @copyright YYYY author.
-
-%% @doc Supervisor for the {{appid}} application.
-
--module({{appid}}_sup).
--author('author <author@example.com>').
-
--behaviour(supervisor).
-
-%% External exports
--export([start_link/0, upgrade/0]).
-
-%% supervisor callbacks
--export([init/1]).
-
-%% @spec start_link() -> ServerRet
-%% @doc API for starting the supervisor.
-start_link() ->
-    supervisor:start_link({local, ?MODULE}, ?MODULE, []).
-
-%% @spec upgrade() -> ok
-%% @doc Add processes if necessary.
-upgrade() ->
-    {ok, {_, Specs}} = init([]),
-
-    Old = sets:from_list(
-	    [Name || {Name, _, _, _} <- supervisor:which_children(?MODULE)]),
-    New = sets:from_list([Name || {Name, _, _, _, _, _} <- Specs]),
-    Kill = sets:subtract(Old, New),
-
-    sets:fold(fun (Id, ok) ->
-		      supervisor:terminate_child(?MODULE, Id),
-		      supervisor:delete_child(?MODULE, Id),
-		      ok
-	      end, ok, Kill),
-
-    [supervisor:start_child(?MODULE, Spec) || Spec <- Specs],
-    ok.
-
-%% @spec init([]) -> SupervisorTree
-%% @doc supervisor callback.
-init([]) ->
-    Ip = case os:getenv("WEBMACHINE_IP") of false -> "0.0.0.0"; Any -> Any end,
-    {ok, Dispatch} = file:consult(filename:join(
-                         [filename:dirname(code:which(?MODULE)),
-                          "..", "priv", "dispatch.conf"])),
-    WebConfig = [
-		 {ip, Ip},
-		 {port, 8000},
-                 {log_dir, "priv/log"},
-		 {dispatch, Dispatch}],
-    Web = {webmachine_mochiweb,
-           {webmachine_mochiweb, start, [WebConfig]},
-           permanent, 5000, worker, dynamic},
-    Processes = [Web],
-    {ok, { {one_for_one, 10, 10}, Processes} }.

priv/templates/start.sh

-#!/bin/sh
-cd `dirname $0`
-exec erl -pa $PWD/ebin $PWD/deps/*/ebin -boot start_sasl -s reloader -s {{appid}}

priv/templates/wmskel.template

-%%-*- mode: erlang -*-
-%% Basic Webmachine application skeleton
-
-%% Variables:
-%%   appid: name of the application to build
-%%          default = "wmskel"
-%%   webmachine: path to webmachine from this template
-%%               default = "../.."
-%%   prefix: path where the application should be created
-%%           default = "."
-{variables, [{appid, "wmskel"},
-             {webmachine, "../.."},
-             {prefix, "."}]}.
-
-%% main project files
-{template, "README", "{{prefix}}/README"}.
-{template, "Makefile", "{{prefix}}/Makefile"}.
-{template, "rebar.config", "{{prefix}}/rebar.config"}.
-{file, "{{webmachine}}/rebar", "{{prefix}}/rebar"}.
-{chmod, 8#744, "{{prefix}}/rebar"}.
-{template, "start.sh", "{{prefix}}/start.sh"}.
-{chmod, 8#744, "{{prefix}}/start.sh"}.
-
-{template, "ebin/wmskel.app", "{{prefix}}/ebin/{{appid}}.app"}.
-
-{template, "src/wmskel.erl", "{{prefix}}/src/{{appid}}.erl"}.
-{template, "src/wmskel_app.erl", "{{prefix}}/src/{{appid}}_app.erl"}.
-{template, "src/wmskel_sup.erl", "{{prefix}}/src/{{appid}}_sup.erl"}.
-{template, "src/wmskel_resource.erl", "{{prefix}}/src/{{appid}}_resource.erl"}.
-
-{template, "priv/dispatch.conf", "{{prefix}}/priv/dispatch.conf"}.
-{dir, "{{prefix}}/priv/www"}.
-
-%% dependencies
-{dir, "{{prefix}}/deps"}.
Add a comment to this file

priv/trace/http-headers-status-v3.png

Removed
Old image

priv/trace/wmtrace.css

-body {
-    margin:0px;
-    padding:0px;
-}
-
-canvas#v3map {
-    margin-top:2em;
-    z-index: 1;
-}
-
-div#sizetest {
-    width:100%;
-}
-
-div#zoompanel {
-    height:2em;
-    position:fixed;
-    z-index:10;
-}
-
-div#preview {
-    position:absolute;
-    display:none;
-    background:#dddddd;
-    border:1px solid #999999;
-}
-
-div#preview ul {
-    padding: 0px 0px 0px 0.5em;
-    margin: 0px;
-    list-style: none;
-}
-
-div#infopanel {
-    z-index:20;
-    background:#dddddd;
-    position:fixed;
-    top:0px;
-    right:0px;
-    bottom:0px;
-    left:75%;
-    min-width:30em;
-    padding:5px;
-}
-
-div#infocontrols {
-    position:absolute;
-    top:0px;
-    bottom:0px;
-    left:-5px;
-    width:5px;
-    background:#999999;
-    cursor:ew-resize;
-}
-
-div#infocontrols div {
-    position:absolute;
-    left:-15px;
-    width:20px;
-    height:49px;
-    background:#999999;
-    cursor:pointer;
-}
-
-div#infocontrols div.selectedtab {
-    background:#dddddd;
-    border-top: 1px solid #999999;
-    border-left: 1px solid #999999;
-    border-bottom: 1px solid #999999;
-}
-
-div#requesttab {
-    top:2px;
-}
-
-div#responsetab {
-    top:54px;
-}
-
-div#decisiontab {
-    top:106px;
-}
-
-div#requestdetail, div#responsedetail, div#decisiondetail {
-    height:100%;
-}
-
-div#responsedetail, div#decisiondetail {
-    display:none;
-}
-
-div#infopanel ul {
-    list-style:none;
-    padding-left:0px;
-    height:5em;
-    overflow-y:scroll;
-}
-
-pre {
-    height:40%;
-    overflow:scroll;
-}
-
-div#responsebody, div#requestbody {
-    height:70%;
-    overflow-y:scroll;
-}

priv/trace/wmtrace.js

-var HIGHLIGHT = '#cc00cc';
-var REGULAR = '#666666';
-
-var cols = {
-    'a':173,
-    'b':325,
-    'c':589,
-    'd':797,
-    'e':1005,
-    'f':1195,
-    'g':1402,
-    'gg':1515,
-    'h':1572,
-    'i':1799,
-    'j':1893,
-    'k':1988,
-    'l':2157,
-    'll':2346,
-    'm':2403,
-    'mm':2535,
-    'n':2554,
-    'o':2649,
-    'oo':2781,
-    'ooo':2801,
-    'p':2894,
-    'q':3007
-};
-
-var rows = {
-    '1':221,
-    '2':298,
-    '3':373,
-    '4':448,
-    '5':524,
-    '6':599,
-    '7':675,
-    '8':751,
-    '9':826,
-    '10':902,
-    '11':977,
-    '12':1053,
-    '13':1129,
-    '14':1204,
-    '15':1280,
-    '16':1355,
-    '17':1431,
-    '18':1506,
-    '19':1583,
-    '20':1658,
-    '21':1734,
-    '22':1809,
-    '23':1885,
-    '24':1961,
-    '25':2036,
-    '26':2112
-};
-
-var edges = {
-    'b14b13':['b14','b13'],
-
-    'b13b12':['b13','b12'],
-    'b13503':['b13','503'],
-
-    'b12b11':['b12','b11'],
-    'b12501':['b12','501'],
-
-    'b11b10':['b11','b10'],
-    'b11414':['b11','414'],
-
-    'b10b9':['b10','b9'],
-    'b10405':['b10','405'],
-
-    'b9b8':['b9','b8'],
-    'b9400':['b9','400'],
-
-    'b8b7':['b8','b7'],
-    'b8401':['b8','401'],
-
-    'b7b6':['b7','b6'],
-    'b7403':['b7','403'],
-
-    'b6b5':['b6','b5'],
-    'b6501':['b6','501a'],
-
-    'b5b4':['b5','b4'],
-    'b5415':['b5','415'],
-
-    'b4b3':['b4','b3'],
-    'b4413':['b4','b4'],
-
-    'b3c3':['b3','c3'],
-    'b3200':['b3','200'],
-
-    'c3c4':['c3','c4'],
-    'c3d4':['c3','d3','d4'],
-
-    'c4d4':['c4','d4'],
-    'c4406':['c4','406'],
-
-    'd4d5':['d4','d5'],
-    'd4e5':['d4','e4','e5'],
-
-    'd5e5':['d5','e5'],
-    'd5406':['d5','d7','406'],
-
-    'e5e6':['e5','e6'],
-    'e5f6':['e5','f5','f6'],
-
-    'e6f6':['e6','f6'],
-    'e6406':['e6','e7','406'],
-
-    'f6f7':['f6','f7'],
-    'f6g7':['f6','g6','g7'],
-
-    'f7g7':['f7','g7'],
-    'f7406':['f7','406'],
-
-    'g7g8':['g7','g8'],
-    'g7h7':['g7','h7'],
-
-    'g8g9':['g8','g9'],
-    'g8h10':['g8','h8','h10'],
-
-    'g9g11':['g9','g11'],
-    'g9h10':['g9','gg9','gg10','h10'],
-
-    'g11h10':['g11','gg11','gg10','h10'],
-    'g11412':['g11','g18','412a'],
-
-    'h7i7':['h7','i7'],
-    'h7412':['h7','412'],
-
-    'h10h11':['h10','h11'],
-    'h10i12':['h10','i10','i12'],
-
-    'h11h12':['h11','h12'],
-    'h11i12':['h11','i11','i12'],
-
-    'h12i12':['h12','i12'],
-    'h12412':['h12','412a'],
-
-    'i4p3':['i4','i3','p3'],
-    'i4301':['i4','301'],
-
-    'i7i4':['i7','i4'],
-    'i7k7':['i7','k7'],
-
-    'i12l13':['i12','l12','l13'],
-    'i12i13':['i12','i13'],
-
-    'i13k13':['i13','k13'],
-    'i13j18':['i13','i17','j17','j18'],
-
-    'j18412':['j18','412a'],
-    'j18304':['j18','304'],
-
-    'k5l5':['k5','l5'],
-    'k5301':['k5','301'],
-
-    'k7k5':['k7','k5'],
-    'k7l7':['k7','l7'],
-
-    'k13j18':['k13','k17','j17','j18'],
-    'k13l13':['k13','l13'],
-
-    'l5m5':['l5','m5'],
-    'l5307':['l5','307'],
-
-    'l7m7':['l7','m7'],
-    'l7404':['l7','l8','404'],
-
-    'l13l14':['l13','l14'],
-    'l13m16':['l13','m13','m16'],
-
-    'l14l15':['l14','l15'],
-    'l14m16':['l14','m14','m16'],
-
-    'l15l17':['l15','l17'],
-    'l15m16':['l15','ll15','ll16','m16'],
-
-    'l17m16':['l17','ll17','ll16','m16'],
-    'l17304':['l17','304'],
-
-    'm5n5':['m5','n5'],
-    'm5410':['m5','m4','410'],
-
-    'm7n11':['m7','n7','n11'],
-    'm7404':['m7','404'],
-
-    'm16m20':['m16','m20'],
-    'm16n16':['m16','n16'],
-
-    'm20o20':['m20','o20'],
-    'm20202':['m20','202'],
-
-    'n5n11':['n5','n11'],
-    'n5410':['n5','410'],
-
-    'n11p11':['n11','p11'],
-    'n11303':['n11','303'],
-
-    'n16n11':['n16','n11'],
-    'n16o16':['n16','o16'],
-
-    'o14p11':['o14','o11','p11'],
-    'o14409':['o14','409a'],
-
-    'o16o14':['o16','o14'],
-    'o16o18':['o16','o18'],
-
-    'o18200':['o18','200a'],
-    'o18300':['o18','oo18','300'],
-
-    'o20o18':['o20','o18'],
-    'o20204':['o20','204'],
-
-    'p3p11':['p3','p11'],
-    'p3409':['p3','409'],
-
-    'p11o20':['p11','p20','o20'],
-    'p11201':['p11','q11','201']
-};
-
-var ends = {
-    '200': {col:'a', row:'3', width:190},
-    '200a': {col:'mm', row:'18', width:116},
-    '201': {col:'q', row:'12', width:154},
-    '202': {col:'m', row:'21', width:116},
-    '204': {col:'o', row:'21', width:152},
-
-    '300': {col:'oo', row:'19', width:152},
-    '301': {col:'k', row:'4', width:154},
-    '303': {col:'m', row:'11', width:116},
-    '304': {col:'l', row:'18', width:116},
-    '307': {col:'l', row:'4', width:154},
-
-    '400': {col:'a', row:'9', width:190},
-    '401': {col:'a', row:'8', width:190},
-    '403': {col:'a', row:'7', width:190},
-    '404': {col:'m', row:'8', width:116},
-    '405': {col:'a', row:'10', width:190},
-    '406': {col:'c', row:'7', width:152},
-    '409': {col:'p', row:'2', width:116},
-    '409a': {col:'oo', row:'14', width:116},
-    '410': {col:'n', row:'4', width:116},
-    '412': {col:'h', row:'6', width:152},
-    '412a': {col:'h', row:'18', width:152},
-    '413': {col:'a', row:'4', width:190},
-    '414': {col:'a', row:'11', width:190},
-    '415': {col:'a', row:'5', width:190},
-
-    '501a': {col:'a', row:'6', width:190},
-    '501': {col:'a', row:'12', width:190},
-    '503': {col:'a', row:'13', width:190}
-};
-
-var canvas;
-
-function decorateTrace() {
-    trace[0].x = cols[trace[0].d[0]];
-    trace[0].y = rows[trace[0].d.slice(1)];
-    trace[0].previewCalls = previewCalls(trace[0]);
-
-    for (var i = 1; i < trace.length; i++) {
-        trace[i].x = cols[trace[i].d[0]];
-        trace[i].y = rows[trace[i].d.slice(1)];
-        trace[i].previewCalls = previewCalls(trace[i]);
-        
-        var path = edges[trace[i-1].d+trace[i].d];
-        if (path) {
-            trace[i].path = [path.length-1];
-            for (var p = 1; p < path.length; p++) {
-                trace[i].path[p-1] = getSeg(path[p-1], path[p], p == path.length-1);
-            }
-        } else {
-            trace[i].path = [];
-        }
-    }
-    
-    var path = edges[trace[i-1].d+response.code];
-    if (path) {
-        var end = ends[path[path.length-1]];
-        response.x = cols[end.col];
-        response.y = rows[end.row];
-        response.width = end.width;
-        response.type = 'normal';
-
-        response.path = [path.length-1];
-        for (var p = 1; p < path.length; p++) {
-            response.path[p-1] = getSeg(path[p-1], path[p], p == path.length-1);
-        }
-    } else {
-        var ld = trace[trace.length-1];
-        response.x = ld.x+50;
-        response.y = ld.y-50;
-        response.width = 38;
-        response.type = 'other';
-
-        response.path = [
-            {x1: ld.x+10, y1: ld.y-10,
-             x2: ld.x+36, y2: ld.y-36}
-        ];
-    }
-};
-
-function previewCalls(dec) {
-    var prev = '';
-    for (var i = 0; i < dec.calls.length; i++) {
-        if (dec.calls[i].output != "wmtrace_not_exported")
-            prev += '<li>'+dec.calls[i].module+':'+dec.calls[i]['function']+'</li>';
-    }
-    return prev;
-};
-
-function drawTrace() {
-    drawDecision(trace[0]);
-    for (var i = 1; i < trace.length; i++) {
-        drawPath(trace[i].path);
-        drawDecision(trace[i]);
-    }
-
-    drawPath(response.path);
-    drawResponse();
-};
-
-function drawResponse() {
-    if (response.type == 'normal') {
-        var context = canvas.getContext('2d');
-        context.strokeStyle=HIGHLIGHT;
-        context.lineWidth=4;
-
-        context.beginPath();
-        context.rect(response.x-(response.width/2),
-                     response.y-19,
-                     response.width,
-                     38);
-        context.stroke();
-    } else {
-        var context = canvas.getContext('2d');
-        context.strokeStyle='#ff0000';
-        context.lineWidth=4;
-
-        context.beginPath();
-        context.arc(response.x, response.y, 19,
-                    0, 2*3.14159, false);
-        context.stroke();
-
-    }
-};
-
-function drawDecision(dec) {
-    var context = canvas.getContext('2d');
-
-    if (dec.previewCalls == '')
-        context.strokeStyle=REGULAR;
-    else
-        context.strokeStyle=HIGHLIGHT;
-    context.lineWidth=4;
-
-    context.beginPath();
-    context.moveTo(dec.x,    dec.y-19);
-    context.lineTo(dec.x+19, dec.y);
-    context.lineTo(dec.x,    dec.y+19);
-    context.lineTo(dec.x-19, dec.y);
-    context.closePath();
-    context.stroke();
-};
-
-function drawPath(path) {
-    var context = canvas.getContext('2d');
-    context.strokeStyle=REGULAR;
-    context.lineWidth=4;
-
-    context.beginPath();
-    context.moveTo(path[0].x1, path[0].y1);
-    for (var p = 0; p < path.length; p++) {
-        context.lineTo(path[p].x2, path[p].y2);
-    }
-    context.stroke();
-};
-
-function getSeg(p1, p2, last) {
-    var seg = {
-        x1:cols[p1[0]],
-        y1:rows[p1.slice(1)]
-    };
-    if (ends[p2]) {
-        seg.x2 = cols[ends[p2].col];
-        seg.y2 = rows[ends[p2].row];
-    } else {
-        seg.x2 = cols[p2[0]];
-        seg.y2 = rows[p2.slice(1)];
-    }
-
-    if (seg.x1 == seg.x2) {
-        if (seg.y1 < seg.y2) {
-            seg.y1 = seg.y1+19;
-            if (last) seg.y2 = seg.y2-19;
-        } else {
-            seg.y1 = seg.y1-19;
-            if (last) seg.y2 = seg.y2+19;
-        }
-    } else {
-        //assume seg.y1 == seg.y2
-        if (seg.x1 < seg.x2) {
-            seg.x1 = seg.x1+19;
-            if (last) seg.x2 = seg.x2-(ends[p2] ? (ends[p2].width/2) : 19);
-        } else {
-            seg.x1 = seg.x1-19;
-            if (last) seg.x2 = seg.x2+(ends[p2] ? (ends[p2].width/2) : 19);
-        }
-    }
-    return seg;
-};
-
-function traceDecision(name) {
-    for (var i = trace.length-1; i >= 0; i--)
-        if (trace[i].d == name) return trace[i];
-};
-
-var detailPanels = {};
-function initDetailPanels() {
-    var windowWidth = document.getElementById('sizetest').clientWidth;
-    var infoPanel = document.getElementById('infopanel');
-    var panelWidth = windowWidth-infoPanel.offsetLeft;
-
-    var panels = {
-        'request': document.getElementById('requestdetail'),
-        'response': document.getElementById('responsedetail'),
-        'decision': document.getElementById('decisiondetail')
-    };
-
-    var tabs = {
-        'request': document.getElementById('requesttab'),
-        'response': document.getElementById('responsetab'),
-        'decision': document.getElementById('decisiontab')
-    };
-
-    var decisionId = document.getElementById('decisionid');
-    var decisionCalls = document.getElementById('decisioncalls');
-    var callInput = document.getElementById('callinput');
-    var callOutput = document.getElementById('calloutput');
-
-    var lastUsedPanelWidth = windowWidth-infoPanel.offsetLeft;
-
-    var setPanelWidth = function(width) {
-        infoPanel.style.left = (windowWidth-width)+'px';
-        canvas.style.marginRight = (width+20)+'px';
-        panelWidth = width;
-    };
-    setPanelWidth(panelWidth);
-
-    var ensureVisible = function() {
-        if (windowWidth-infoPanel.offsetLeft < 10)
-            setPanelWidth(lastUsedPanelWidth);
-    };
-
-    var decChoices = '';
-    for (var i = 0; i < trace.length; i++) {
-        decChoices += '<option value="'+trace[i].d+'">'+trace[i].d+'</option>';
-    }
-    decisionId.innerHTML = decChoices;
-    decisionId.selectedIndex = -1;
-
-    decisionId.onchange = function() {
-        detailPanels.setDecision(traceDecision(decisionId.value));
-    }
-
-    detailPanels.setDecision = function(dec) {
-        decisionId.value = dec.d;
-
-        var calls = [];
-        for (var i = 0; i < dec.calls.length; i++) {
-            calls.push('<option value="'+dec.d+'-'+i+'">');
-            calls.push(dec.calls[i].module+':'+dec.calls[i]['function']);
-            calls.push('</option>');
-        }
-        decisionCalls.innerHTML = calls.join('');
-        decisionCalls.selectedIndex = 0;
-
-        decisionCalls.onchange();
-    };
-
-    detailPanels.show = function(name) {
-        for (p in panels) {
-            if (p == name) {
-                panels[p].style.display = 'block';
-                tabs[p].className = 'selectedtab';
-            }
-            else {
-                panels[p].style.display = 'none';
-                tabs[p].className = '';
-            }
-        }
-        ensureVisible();
-    };
-
-    detailPanels.hide = function() {
-        setPanelWidth(0);
-    }
-
-    decisionCalls.onchange = function() {
-        var val = decisionCalls.value;
-        if (val) {
-            var dec = traceDecision(val.substring(0, val.indexOf('-')));
-            var call = dec.calls[parseInt(val.substring(val.indexOf('-')+1, val.length))];
-
-            if (call.output != "wmtrace_not_exported") {
-                callInput.style.color='#000000';
-                callInput.innerHTML = call.input;
-                if (call.output != null) {
-                    callOutput.style.color = '#000000';
-                    callOutput.innerHTML = call.output;
-                } else {
-                    callOutput.style.color = '#ff0000';
-                    callOutput.textContent = 'Error: '+call.module+':'+call['function']+' never returned';
-                }
-            } else {
-                callInput.style.color='#999999';
-                callInput.textContent = call.module+':'+call['function']+' was not exported';
-                callOutput.textContent = '';
-            }
-        } else {
-            callInput.textContent = '';
-            callOutput.textContent = '';
-        }
-    };
-
-    var headersList = function(headers) {
-        var h = '';
-        for (n in headers) h += '<li>'+n+': '+headers[n];
-        return h;
-    };
-
-    document.getElementById('requestmethod').innerHTML = request.method;
-    document.getElementById('requestpath').innerHTML = request.path;
-    document.getElementById('requestheaders').innerHTML = headersList(request.headers);
-    document.getElementById('requestbody').innerHTML = request.body;
-
-    document.getElementById('responsecode').innerHTML = response.code;
-    document.getElementById('responseheaders').innerHTML = headersList(response.headers);
-    document.getElementById('responsebody').innerHTML = response.body;
-
-
-    var infoControls = document.getElementById('infocontrols');
-    var md = false;
-    var dragged = false;
-    var msoff = 0;
-    infoControls.onmousedown = function(ev) {
-        md = true;
-        dragged = false;
-        msoff = ev.clientX-infoPanel.offsetLeft;
-    };
-
-    infoControls.onclick = function(ev) {
-        if (dragged) {
-            lastUsedPanelWidth = panelWidth;
-        }
-        else if (panelWidth < 10) {
-            switch(ev.target.id) {
-            case 'requesttab': detailPanels.show('request'); break;
-            case 'responsetab': detailPanels.show('response'); break;
-            case 'decisiontab': detailPanels.show('decision'); break;
-            default: ensureVisible();
-            }
-        } else {
-            var name = 'none';
-            switch(ev.target.id) {
-            case 'requesttab': name = 'request'; break;
-            case 'responsetab': name = 'response'; break;
-            case 'decisiontab': name = 'decision'; break;
-            }
-
-            if (panels[name] && panels[name].style.display != 'block')
-                detailPanels.show(name);
-            else
-                detailPanels.hide();
-        }
-
-        return false;
-    };
-
-    document.onmousemove = function(ev) {
-        if (md) {
-            dragged = true;
-            panelWidth = windowWidth-(ev.clientX-msoff);
-            if (panelWidth < 0) {
-                panelWidth = 0;
-                infoPanel.style.left = windowWidth+"px";
-            }
-            else if (panelWidth > windowWidth-21) {
-                panelWidth = windowWidth-21;
-                infoPanel.style.left = '21px';
-            }
-            else
-                infoPanel.style.left = (ev.clientX-msoff)+"px";
-
-            canvas.style.marginRight = panelWidth+20+"px";
-            return false;
-        }
-    };
-
-    document.onmouseup = function() { md = false; };
-
-    window.onresize = function() {
-        windowWidth = document.getElementById('sizetest').clientWidth;
-        infoPanel.style.left = windowWidth-panelWidth+'px';
-    };
-};
-
-window.onload = function() {
-    canvas = document.getElementById('v3map');
-
-    initDetailPanels();
-
-    var scale = 0.25;
-    var coy = canvas.offsetTop;
-    function findDecision(ev) {
-        var x = (ev.clientX+window.pageXOffset)/scale;
-        var y = (ev.clientY+window.pageYOffset-coy)/scale;
-
-        for (var i = trace.length-1; i >= 0; i--) {
-            if (x >= trace[i].x-19 && x <= trace[i].x+19 &&
-                y >= trace[i].y-19 && y <= trace[i].y+19)
-                return trace[i];
-        }
-    };
-
-    var preview = document.getElementById('preview');
-    var previewId = document.getElementById('previewid');
-    var previewCalls = document.getElementById('previewcalls');
-    function previewDecision(dec) {
-        preview.style.left = (dec.x*scale)+'px';
-        preview.style.top = (dec.y*scale+coy+15)+'px';
-        preview.style.display = 'block';
-        previewId.textContent = dec.d;
-
-        previewCalls.innerHTML = dec.previewCalls;
-    };
-
-    function overResponse(ev) {
-        var x = (ev.clientX+window.pageXOffset)/scale;
-        var y = (ev.clientY+window.pageYOffset-coy)/scale;
-        
-        return (x >= response.x-(response.width/2)
-                && x <= response.x+(response.width/2)
-                && y >= response.y-19 && y <= response.y+19);
-    };
-
-    decorateTrace();
-
-    var bg = new Image(3138, 2184);
-
-    function drawMap() {
-        var ctx = canvas.getContext("2d");
-
-        ctx.save();
-        ctx.scale(1/scale, 1/scale);
-        ctx.fillStyle = '#ffffff';
-        ctx.fillRect(0, 0, 3138, 2184);
-        ctx.restore();
-
-        ctx.drawImage(bg, 0, 0);
-        drawTrace();
-    };
-
-    bg.onload = function() {
-        canvas.getContext("2d").scale(scale, scale);
-        drawMap(scale);
-
-        canvas.onmousemove = function(ev) {
-            if (findDecision(ev)) {
-                canvas.style.cursor = 'pointer';
-                previewDecision(findDecision(ev));
-            }
-            else {
-                preview.style.display = 'none';
-                if (overResponse(ev))
-                    canvas.style.cursor = 'pointer';
-                else
-                    canvas.style.cursor = 'default';
-            }
-        };
-
-        canvas.onclick = function(ev) {
-            var dec = findDecision(ev);
-            if (dec) {
-                detailPanels.setDecision(dec);
-                detailPanels.show('decision');
-            } else if (overResponse(ev)) {
-                detailPanels.show('response');
-            }
-        };
-
-        document.getElementById('zoomin').onclick = function() {
-            scale = scale*2;
-            canvas.getContext("2d").scale(2, 2);
-            drawMap();
-        };
- 
-        document.getElementById('zoomout').onclick = function() {
-            scale = scale/2;
-            canvas.getContext("2d").scale(0.5, 0.5);
-            drawMap();
-        };
-    };
-
-    bg.onerror = function() {
-        alert('Failed to load background image.');
-    };
-
-    bg.src = 'static/map.png';
-};

priv/www/index.html

-<html>
-<head>
-<title>It Worked</title>
-</head>
-<body>
-Running.
-</body>
-</html>

Binary file removed.

rebar.config

-%%-*- mode: erlang -*-
-{fail_on_warning, true}.
-
-{deps, [
-        {mochiweb, "1.7.0", {hg, "http://bitbucket.org/basho/mochiweb",
-                            "tip"}}
-        ]}.

scripts/new_webmachine.sh

-#!/bin/bash
-
-NAME=$1
-DESTDIR=$2
-
-if [ -z $NAME ] || [[ $NAME =~ ^[\.\~\/] ]]; then
-    echo "usage: new_webmachine.sh name [destdir]"
-    exit 1
-fi
-
-if [ -z $DESTDIR ]; then
-    DESTDIR="."
-elif [[ $DESTDIR =~ /${NAME}$ ]]; then
-    DESTDIR=${DESTDIR%/*}
-fi
-
-if [ ! -e $DESTDIR ]; then
-    $(mkdir -p $DESTDIR)
-fi
-
-ABSDEST=$(cd $DESTDIR && pwd)
-
-cd ${0%/*}/../priv
-
-../rebar create template=wmskel appid=$NAME prefix=$ABSDEST/$NAME

scripts/run_tests.escript

-#!/usr/bin/env escript
-%% -*- erlang -*-
-%%! -name wm_test@127.0.0.1
-main([Ebin]) ->
-    code:add_path(Ebin),
-    code:add_paths(filelib:wildcard("deps/*/ebin", Ebin)),
-    code:add_paths(filelib:wildcard("deps/*/deps/*/ebin", Ebin)),
-
-    {ok, [{application, webmachine, App}]} =
-        file:consult(filename:join([Ebin, "webmachine.app"])),
-    {ok, NonTestRe} = re:compile("_tests$"),
-    Modules = lists:filter(
-                fun(M) when M =:= gen_server2 ->
-                        false;
-                   (M) when M =:= priority_queue ->
-                        false;
-                   (M) when M =:= json_pp ->
-                        false;
-                   (M) ->
-                        nomatch == re:run(atom_to_list(M), NonTestRe)
-                end,
-                proplists:get_value(modules, App)),
-    
-    crypto:start(),
-    start_cover(Modules),
-    eunit:test(Modules, [verbose]),
-    analyze_cover(Modules);
-main(_) ->
-    io:format("usage: run_tests.escript RIAK_EBIN_DIRECTORY~n"),
-    halt(1).
-
-start_cover(Modules) ->
-    {ok, _Cover} = cover:start(),
-    io:format("Cover compiling...~n"),
-    Compiled = [ M || {ok, M} <- [ cover:compile(
-                                     filename:join(["src",atom_to_list(M)]))
-                                   || M <- Modules ] ],
-    case length(Modules) == length(Compiled) of
-        true -> ok;
-        false ->
-            io:format("Warning: the following modules were not"
-                      " cover-compiled:~n   ~p~n", [Compiled])
-    end.
-
-analyze_cover(Modules) ->
-    io:format("Analyzing cover...~n"),
-    CoverBase = filename:join(["test", "cover"]),
-    ok = filelib:ensure_dir(filename:join([CoverBase, "fake"])),
-    Coverages = lists:foldl(
-                  fun(M, Acc) ->
-                          [analyze_module(CoverBase, M)|Acc]
-                  end,
-                  [], Modules),
-    IndexFilename = filename:join([CoverBase, "index.html"]),
-    {ok, Index} = file:open(IndexFilename, [write]),
-    {LineTotal, CoverTotal} = 
-        lists:foldl(fun({_,_,Lines,Covered}, {LineAcc, CovAcc}) ->
-                            {LineAcc+Lines, CovAcc+Covered}
-                    end, {0,0}, Coverages),
-    file:write(Index,
-               "<html><head><title>Riak Coverage</title></head>\n"
-               "<body><h1>Riak Coverage</h1><ul>\n"),
-    file:write(Index,
-               io_lib:format("<h2>Total: ~.2f%</h2>\n",
-                             [percentage(CoverTotal, LineTotal)])),
-    [ file:write(Index,
-                 io_lib:format(
-                   "<li><a href=\"~s\">~p</a>: ~.2f%</li>~n",
-                   [Filename, Module, percentage(Covered, Lines)]))
-      || {Filename, Module, Lines, Covered} <- Coverages ],
-    file:write(Index,"</ul></body></html>"),
-    file:close(Index),
-    io:format("Cover analysis in ~s~n", [IndexFilename]).
-
-analyze_module(CoverBase, Module) ->
-    {ok, Filename} = 
-        cover:analyze_to_file(
-          Module,
-          filename:join(CoverBase, atom_to_list(Module)++".COVER.html"),
-          [html]),
-    Lines = count_lines(Filename, "[[:digit:]]\.\.|"),
-    Covered = count_lines(Filename, "[[:space:]]0\.\.|"),
-    {filename:basename(Filename), Module, Lines, Lines-Covered}.
-
-count_lines(Filename, Pattern) ->
-    {ok, [Lines],_} = io_lib:fread(
-                        "~d",
-                        os:cmd(io_lib:format("grep -e \"~s\" ~s | wc -l",
-                                             [Pattern, Filename]))),
-    Lines.
-
-percentage(_, 0) -> 1000.0;
-percentage(Part, Total) ->
-    (Part/Total)*100.
-

src/webmachine.erl

-%% @author Justin Sheehy <justin@basho.com>
-%% @author Andy Gross <andy@basho.com>
-%% @copyright 2007-2009 Basho Technologies
-%%
-%%    Licensed under the Apache License, Version 2.0 (the "License");
-%%    you may not use this file except in compliance with the License.
-%%    You may obtain a copy of the License at
-%%
-%%        http://www.apache.org/licenses/LICENSE-2.0
-%%
-%%    Unless required by applicable law or agreed to in writing, software
-%%    distributed under the License is distributed on an "AS IS" BASIS,
-%%    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-%%    See the License for the specific language governing permissions and
-%%    limitations under the License.
-
--module(webmachine).
--author('Justin Sheehy <justin@basho.com>').
--author('Andy Gross <andy@basho.com>').
--export([start/0, stop/0]).
--export([new_request/2]).
-
--include("webmachine_logger.hrl").
--include_lib("include/wm_reqstate.hrl").
--include_lib("include/wm_reqdata.hrl").
-
-%% @spec start() -> ok
-%% @doc Start the webmachine server.
-start() ->
-    webmachine_deps:ensure(),
-    application:start(crypto),
-    application:start(webmachine).
-
-%% @spec stop() -> ok
-%% @doc Stop the webmachine server.
-stop() ->
-    application:stop(webmachine).
-
-new_request(mochiweb, Request) ->
-    Socket = Request:get(socket),
-    Method = Request:get(method),
-    RawPath = Request:get(raw_path), 
-    Version = Request:get(version),
-    Headers = Request:get(headers),
-    InitState = #wm_reqstate{socket=Socket,
-                          reqdata=wrq:create(Method,Version,RawPath,Headers)},
-    
-    InitReq = {webmachine_request,InitState},
-    {Peer, ReqState} = InitReq:get_peer(),
-    PeerState = ReqState#wm_reqstate{reqdata=wrq:set_peer(Peer,
-                                              ReqState#wm_reqstate.reqdata)},
-    LogData = #wm_log_data{start_time=now(),
-			   method=Method,
-			   headers=Headers,
-			   peer=PeerState#wm_reqstate.peer,
-			   path=RawPath,
-			   version=Version,
-			   response_code=404,
-			   response_length=0},
-    webmachine_request:new(PeerState#wm_reqstate{log_data=LogData}).
-
-
-
-
-  

src/webmachine_app.erl

-%% @author Justin Sheehy <justin@basho.com>
-%% @author Andy Gross <andy@basho.com>
-%% @copyright 2007-2008 Basho Technologies
-%%
-%%    Licensed under the Apache License, Version 2.0 (the "License");
-%%    you may not use this file except in compliance with the License.
-%%    You may obtain a copy of the License at
-%%
-%%        http://www.apache.org/licenses/LICENSE-2.0
-%%
-%%    Unless required by applicable law or agreed to in writing, software
-%%    distributed under the License is distributed on an "AS IS" BASIS,
-%%    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-%%    See the License for the specific language governing permissions and
-%%    limitations under the License.
-
-%% @doc Callbacks for the webmachine application.
-
--module(webmachine_app).
--author('Justin Sheehy <justin@basho.com>').
--author('Andy Gross <andy@basho.com>').
-
--behaviour(application).
--export([start/2,stop/1]).
-
-
-%% @spec start(_Type, _StartArgs) -> ServerRet
-%% @doc application start callback for webmachine.
-start(_Type, _StartArgs) ->
-    webmachine_deps:ensure(),
-    webmachine_sup:start_link().
-
-%% @spec stop(_State) -> ServerRet
-%% @doc application stop callback for webmachine.
-stop(_State) ->
-    ok.

src/webmachine_decision_core.erl

-%% @author Justin Sheehy <justin@basho.com>
-%% @author Andy Gross <andy@basho.com>
-%% @author Bryan Fink <bryan@basho.com>
-%% @copyright 2007-2009 Basho Technologies
-%%
-%%    Licensed under the Apache License, Version 2.0 (the "License");
-%%    you may not use this file except in compliance with the License.
-%%    You may obtain a copy of the License at
-%%
-%%        http://www.apache.org/licenses/LICENSE-2.0
-%%
-%%    Unless required by applicable law or agreed to in writing, software
-%%    distributed under the License is distributed on an "AS IS" BASIS,
-%%    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-%%    See the License for the specific language governing permissions and
-%%    limitations under the License.