diff --git a/deps/rabbitmq_web_dispatch/README.md b/deps/rabbitmq_web_dispatch/README.md index 6051903642..425ef6ddc9 100644 --- a/deps/rabbitmq_web_dispatch/README.md +++ b/deps/rabbitmq_web_dispatch/README.md @@ -1,7 +1,7 @@ -rabbitmq-mochiweb ------------------ +rabbitmq-web-dispatch +--------------------- -rabbitmq-mochiweb is a thin veneer around mochiweb that provides the +rabbitmq-web-dispatch is a thin veneer around mochiweb that provides the ability for multiple applications to co-exist on mochiweb listeners. Applications can register static docroots or dynamic handlers to be executed, dispatched by URL path prefix. @@ -10,14 +10,14 @@ See http://www.rabbitmq.com/mochiweb.html for information on configuring web plugins. The most general registration procedure is -`rabbit_mochiweb:register_context_handler/5`. This takes a callback +`rabbit_web_dispatch:register_context_handler/5`. This takes a callback procedure of the form loop(Request) -> ... The module `rabbit_webmachine` provides a means of running more than -one webmachine in a VM, and understands rabbitmq-mochiweb contexts. To +one webmachine in a VM, and understands rabbitmq-web-dispatch contexts. To use it, supply a dispatch table term of the kind usually given to webmachine in the file `priv/dispatch.conf`. diff --git a/deps/rabbitmq_web_dispatch/src/rabbit_mochiweb.erl b/deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch.erl similarity index 96% rename from deps/rabbitmq_web_dispatch/src/rabbit_mochiweb.erl rename to deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch.erl index 97cd1ec897..1dcf3404d1 100644 --- a/deps/rabbitmq_web_dispatch/src/rabbit_mochiweb.erl +++ b/deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch.erl @@ -14,20 +14,18 @@ %% Copyright (c) 2010-2013 VMware, Inc. All rights reserved. %% --module(rabbit_mochiweb). +-module(rabbit_web_dispatch). -export([register_context_handler/5, register_static_context/6]). -export([register_port_redirect/4]). -export([unregister_context/1]). --define(APP, rabbitmq_mochiweb). - %% Handler Registration %% Registers a dynamic selector and handler combination, with a link %% to display in lists. register_handler(Name, Listener, Selector, Handler, Link) -> - rabbit_mochiweb_registry:add(Name, Listener, Selector, Handler, Link). + rabbit_web_dispatch_registry:add(Name, Listener, Selector, Handler, Link). %% Methods for standard use cases @@ -112,5 +110,5 @@ serve_file(Req, Path, LocalPath) -> %% The opposite of all those register_* functions. unregister_context(Name) -> - rabbit_mochiweb_registry:remove(Name). + rabbit_web_dispatch_registry:remove(Name). diff --git a/deps/rabbitmq_web_dispatch/src/rabbit_mochiweb_app.erl b/deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch_app.erl similarity index 79% rename from deps/rabbitmq_web_dispatch/src/rabbit_mochiweb_app.erl rename to deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch_app.erl index ef2aaac62c..97603a0d54 100644 --- a/deps/rabbitmq_web_dispatch/src/rabbit_mochiweb_app.erl +++ b/deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch_app.erl @@ -14,19 +14,17 @@ %% Copyright (c) 2010-2013 VMware, Inc. All rights reserved. %% --module(rabbit_mochiweb_app). +-module(rabbit_web_dispatch_app). -behaviour(application). -export([start/2,stop/1]). --define(APP, rabbitmq_mochiweb). - %% @spec start(_Type, _StartArgs) -> ServerRet -%% @doc application start callback for rabbit_mochiweb. +%% @doc application start callback for rabbit_web_dispatch. start(_Type, _StartArgs) -> - rabbit_mochiweb_sup:start_link(). + rabbit_web_dispatch_sup:start_link(). %% @spec stop(_State) -> ServerRet -%% @doc application stop callback for rabbit_mochiweb. +%% @doc application stop callback for rabbit_web_dispatch. stop(_State) -> ok. diff --git a/deps/rabbitmq_web_dispatch/src/rabbit_mochiweb_registry.erl b/deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch_registry.erl similarity index 94% rename from deps/rabbitmq_web_dispatch/src/rabbit_mochiweb_registry.erl rename to deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch_registry.erl index ccbb10fba0..777ef123db 100644 --- a/deps/rabbitmq_web_dispatch/src/rabbit_mochiweb_registry.erl +++ b/deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch_registry.erl @@ -14,7 +14,7 @@ %% Copyright (c) 2010-2013 VMware, Inc. All rights reserved. %% --module(rabbit_mochiweb_registry). +-module(rabbit_web_dispatch_registry). -behaviour(gen_server). @@ -23,7 +23,7 @@ -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). --define(ETS, rabbitmq_mochiweb). +-define(ETS, rabbitmq_web_dispatch). %% This gen_server is merely to serialise modifications to the dispatch %% table for listeners. @@ -55,7 +55,7 @@ lookup(Listener, Req) -> end. %% This is called in a somewhat obfuscated manner in -%% rabbit_mgmt_external_stats:rabbit_mochiweb_registry_list_all() +%% rabbit_mgmt_external_stats:rabbit_web_dispatch_registry_list_all() list_all() -> gen_server:call(?MODULE, list_all, infinity). @@ -67,7 +67,7 @@ init([]) -> handle_call({add, Name, Listener, Selector, Handler, Link = {_, Desc}}, _From, undefined) -> - Continue = case rabbit_mochiweb_sup:ensure_listener(Listener) of + Continue = case rabbit_web_dispatch_sup:ensure_listener(Listener) of new -> set_dispatch( Listener, [], listing_fallback_handler(Listener)), @@ -97,7 +97,7 @@ handle_call({remove, Name}, _From, Selectors1 = lists:keydelete(Name, 1, Selectors), set_dispatch(Listener, Selectors1, Fallback), case Selectors1 of - [] -> rabbit_mochiweb_sup:stop_listener(Listener); + [] -> rabbit_web_dispatch_sup:stop_listener(Listener); _ -> ok end, {reply, ok, undefined}; @@ -196,4 +196,4 @@ listing_fallback_handler(Listener) -> handler_listing(Path, ReqPath, Desc) -> io_lib:format( "
  • ~s
  • ", - [rabbit_mochiweb_util:relativise(ReqPath, "/" ++ Path), Desc]). + [rabbit_web_dispatch_util:relativise(ReqPath, "/" ++ Path), Desc]). diff --git a/deps/rabbitmq_web_dispatch/src/rabbit_mochiweb_sup.erl b/deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch_sup.erl similarity index 88% rename from deps/rabbitmq_web_dispatch/src/rabbit_mochiweb_sup.erl rename to deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch_sup.erl index 5afae5675c..81d5329350 100644 --- a/deps/rabbitmq_web_dispatch/src/rabbit_mochiweb_sup.erl +++ b/deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch_sup.erl @@ -14,7 +14,7 @@ %% Copyright (c) 2010-2013 VMware, Inc. All rights reserved. %% --module(rabbit_mochiweb_sup). +-module(rabbit_web_dispatch_sup). -behaviour(supervisor). @@ -36,7 +36,7 @@ ensure_listener(Listener) -> undefined -> {error, {no_port_given, Listener}}; _ -> - Child = {{rabbit_mochiweb_web, name(Listener)}, + Child = {{rabbit_web_dispatch_web, name(Listener)}, {mochiweb_http, start, [mochi_options(Listener)]}, transient, 5000, worker, dynamic}, case supervisor:start_child(?SUP, Child) of @@ -48,14 +48,14 @@ ensure_listener(Listener) -> stop_listener(Listener) -> Name = name(Listener), - ok = supervisor:terminate_child(?SUP, {rabbit_mochiweb_web, Name}), - ok = supervisor:delete_child(?SUP, {rabbit_mochiweb_web, Name}). + ok = supervisor:terminate_child(?SUP, {rabbit_web_dispatch_web, Name}), + ok = supervisor:delete_child(?SUP, {rabbit_web_dispatch_web, Name}). %% @spec init([[instance()]]) -> SupervisorTree %% @doc supervisor callback. init([]) -> - Registry = {rabbit_mochiweb_registry, - {rabbit_mochiweb_registry, start_link, []}, + Registry = {rabbit_web_dispatch_registry, + {rabbit_web_dispatch_registry, start_link, []}, transient, 5000, worker, dynamic}, {ok, {{one_for_one, 10, 10}, [Registry]}}. @@ -69,7 +69,7 @@ mochi_options(Listener) -> loopfun(Listener) -> fun (Req) -> - case rabbit_mochiweb_registry:lookup(Listener, Req) of + case rabbit_web_dispatch_registry:lookup(Listener, Req) of no_handler -> Req:not_found(); {error, Reason} -> diff --git a/deps/rabbitmq_web_dispatch/src/rabbit_mochiweb_util.erl b/deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch_util.erl similarity index 97% rename from deps/rabbitmq_web_dispatch/src/rabbit_mochiweb_util.erl rename to deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch_util.erl index 3fd1526d0d..ef6ac23d0d 100644 --- a/deps/rabbitmq_web_dispatch/src/rabbit_mochiweb_util.erl +++ b/deps/rabbitmq_web_dispatch/src/rabbit_web_dispatch_util.erl @@ -14,7 +14,7 @@ %% Copyright (c) 2010-2013 VMware, Inc. All rights reserved. %% --module(rabbit_mochiweb_util). +-module(rabbit_web_dispatch_util). -export([parse_auth_header/1]). -export([relativise/2]). diff --git a/deps/rabbitmq_web_dispatch/src/rabbit_webmachine.erl b/deps/rabbitmq_web_dispatch/src/rabbit_webmachine.erl index 073c9f8975..557066d848 100644 --- a/deps/rabbitmq_web_dispatch/src/rabbit_webmachine.erl +++ b/deps/rabbitmq_web_dispatch/src/rabbit_webmachine.erl @@ -8,13 +8,13 @@ %% An alternative to webmachine_mochiweb, which places the dispatch %% table (among other things) into the application env, and thereby %% makes it impossible to run more than one instance of -%% webmachine. Since rabbit_mochiweb is all about multi-tenanting +%% webmachine. Since rabbit_web_dispatch is all about multi-tenanting %% webapps, clearly this won't do for us. %% Instead of using webmachine_mochiweb:start/1 or %% webmachine_mochiweb:loop/1, construct a loop procedure using %% makeloop/1 and supply it as the argument to -%% rabbit_mochiweb:register_context_handler or to mochiweb_http:start. +%% rabbit_web_dispatch:register_context_handler or to mochiweb_http:start. %% We hardwire the "error handler" and use a "logging module" if %% supplied. diff --git a/deps/rabbitmq_web_dispatch/src/rabbitmq_mochiweb.app.src b/deps/rabbitmq_web_dispatch/src/rabbitmq_web_dispatch.app.src similarity index 51% rename from deps/rabbitmq_web_dispatch/src/rabbitmq_mochiweb.app.src rename to deps/rabbitmq_web_dispatch/src/rabbitmq_web_dispatch.app.src index f44fbe7617..5e7dd4d3c2 100644 --- a/deps/rabbitmq_web_dispatch/src/rabbitmq_mochiweb.app.src +++ b/deps/rabbitmq_web_dispatch/src/rabbitmq_web_dispatch.app.src @@ -1,8 +1,8 @@ -{application, rabbitmq_mochiweb, - [{description, "RabbitMQ Mochiweb Embedding"}, +{application, rabbitmq_web_dispatch, + [{description, "RabbitMQ Web Dispatcher"}, {vsn, "%%VSN%%"}, {modules, []}, {registered, []}, - {mod, {rabbit_mochiweb_app, []}}, + {mod, {rabbit_web_dispatch_app, []}}, {env, []}, {applications, [kernel, stdlib, mochiweb, webmachine]}]}.