httpxmppprosody-im

Is it possible for a Prosody server to make an HTTP request to an external API


The Prosody server has several modules that allow it to respond to HTTP requests.

For example, mod_http_rest allows me to make a POST request on port 5280 with an XMPP stanza as the payload, and the Prosody server responds by sending that stanza on its way.

However, I am looking for a module that would do the opposite: i.e. take an XMPP message received by the usual means, and make an HTTP POST request to a specified server with that message as the payload.

I can't seem to find any module that will do this. Is there such a thing?

If not, is there any functionality available in the Prosody API that would allow such a module to be written?

Alternatively, are there good reasons why this might be a bad idea?


Solution

  • To answer your question, yes, it's possible for Prosody to make HTTP requests to external services.

    The module you describe (take XMPP and forward it over HTTP) did not exist, but there's little reason for it not to. So I just published a module that provides this feature: https://modules.prosody.im/mod_component_http.html