0

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?

4

2 回答 2

2

I dont known if there is a module already for that but there is a way to achieve it yourself. I made my own module some months back for specific purposes and I used net.http which as the Docs say:

Is an API for making non-blocking HTTP requests to remote servers.

So you should check the Docs from here so you can use it like:

local req = require "net.http"
req.request( URL, opts, callBack )

Where opts are your options in json, and callBack is a function that defines what you want to do with the response.

I hope it helps.

于 2018-03-23T16:38:55.320 回答
2

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

于 2018-03-26T12:54:59.653 回答