Software /
code /
prosody-modules
Comparison
mod_rest/mod_rest.lua @ 4917:9d0ec61c70a1
mod_rest: Catch and coerce errors in echo endpoint
This should ensure problems in encode() are reported back
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 07 Apr 2022 17:48:08 +0200 |
parent | 4888:dc7c9ae15f43 |
child | 4918:347e34c3c7e2 |
comparison
equal
deleted
inserted
replaced
4916:3dc8e329d233 | 4917:9d0ec61c70a1 |
---|---|
330 | 330 |
331 module:log("debug", "Received[rest]: %s", payload:top_tag()); | 331 module:log("debug", "Received[rest]: %s", payload:top_tag()); |
332 local send_type = decide_type((request.headers.accept or "") ..",".. (request.headers.content_type or ""), supported_outputs) | 332 local send_type = decide_type((request.headers.accept or "") ..",".. (request.headers.content_type or ""), supported_outputs) |
333 | 333 |
334 if echo then | 334 if echo then |
335 local ret, err = errors.coerce(encode(send_type, payload)); | |
336 if not ret then return err; end | |
335 response.headers.content_type = send_type; | 337 response.headers.content_type = send_type; |
336 return encode(send_type, payload); | 338 return ret; |
337 end | 339 end |
338 | 340 |
339 if payload.name == "iq" then | 341 if payload.name == "iq" then |
340 local responses = st.stanza("xmpp"); | 342 local responses = st.stanza("xmpp"); |
341 function origin.send(stanza) | 343 function origin.send(stanza) |