# HG changeset patch # User Kim Alvefur # Date 1616283113 -3600 # Node ID 81d0748bff5b43e84ec12b01fb5044b46c4d5f70 # Parent ade2064160e34286dbc615d79415c3a6cd6d8657 mod_rest: Add an 'echo' endpoint for debugging It returns the XML stanza built from e.g. the JSON format. diff -r ade2064160e3 -r 81d0748bff5b mod_rest/mod_rest.lua --- a/mod_rest/mod_rest.lua Wed Mar 17 15:52:12 2021 +0100 +++ b/mod_rest/mod_rest.lua Sun Mar 21 00:31:53 2021 +0100 @@ -231,6 +231,8 @@ local request, response = event.request, event.response; local from; local origin; + local echo = path == "echo"; + if echo then path = nil; end if not request.headers.authorization then response.headers.www_authenticate = www_authenticate_header; @@ -285,6 +287,12 @@ module:log("debug", "Received[rest]: %s", payload:top_tag()); local send_type = decide_type((request.headers.accept or "") ..",".. (request.headers.content_type or ""), supported_outputs) + + if echo then + response.headers.content_type = send_type; + return encode(send_type, payload); + end + if payload.name == "iq" then function origin.send(stanza) module:send(stanza);