As part of a push to reduce the number of dependencies from the
RabbitMQ project, the management plugin needed to be converted
from Webmachine to Cowboy REST. This plugin provides a convenient
interface to listeners, which had to be converted from Mochiweb's
to Cowboy's also.
Because Cowboy does not have any logging built-in we keep
Webmachine's access logger for now. It has been adapted to use
data coming from Cowboy, as opposed to Mochiweb. The event handler
for logging has also been moved to web dispatch.
The main breaking change in the interface is that contexts do not
take a fun for the main loop anymore, but instead take a dispatch
list of the routes to be served by that context. Routes must be
compiled using cowboy_router:compile(Routes), and will be served
with the context prefix appended.
Some contexts do not require any code change, including the static
contexts and port redirect contexts.
To serve many applications, we use a Cowboy middleware specific
to RabbitMQ which, when receiving a request, checks in the registry
if there is a matching application, and use its dispatch list for
any subsequent operations.