[rabbitmq-discuss] Docs/Advice on extending HTTP API

Dushin Fred fred at dushin.net
Tue Aug 27 01:27:27 BST 2013

I have some administrative operations I would like to add, via an additional plugin (OTP application), to a RabbitMQ instance.  I have reasonably successful writing a few generic plugins, which as I understand it are basically just OTP applications that have been registered with RabbitMQ, but I am having some difficulty fully understanding how to interface with mochiweb to add operations to the REST API.  (I am less interested in making changes to the WebUI, but understanding how to do that would be a bonus.)

So far, I have copied the rabbitmq_shovel_management plugin (using the 3.1.5 branch on rabbitmq-public-umbrella), as a guide, and I have managed to insert my own dummy code for get operations, and I can do an HTTP GET to get the data that the plugin is providing, e.g., via


init(_Config) -> {ok, #context{}}.

content_types_provided(ReqData, Context) ->
   {[{"application/json", to_json}], ReqData, Context}.

to_json(ReqData, Context) ->
    rabbit_mgmt_util:reply(status(), ReqData, Context).

is_authorized(ReqData, Context) ->
    rabbit_mgmt_util:is_authorized_admin(ReqData, Context).


status() ->
	[{name, <<"foo">>}, {node, <<"bar">>} ].

I am now interested in using PUT and POST operations to pass parameters to allow state mutation on the server (a la REST principles).

I don't suppose there is any documentation on anything more than the metronome sample plugin.  Is there a simple example to follow, in the umbrella code, that would give me an architectural understanding of how the rabbit_mgmt_extension behavior can be leveraged?

Short of that, can anyone explain the roles of the following functions?



Who calls them?  When are they called?  Can anything general be said about the parameters to these functions?   (Yes, I too can use io:format :)

Sorry for the somewhat vague set of questions, but I haven't gotten cozy with mochiweb (though I have done some work with YAWS), so I am just hunting for a few pointers.

Thanks in advance,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130826/6e196b4a/attachment.htm>

More information about the rabbitmq-discuss mailing list