mod_rest: Catch and coerce errors in echo endpoint
This should ensure problems in encode() are reported back
--- a/mod_rest/mod_rest.lua Thu Apr 07 15:39:57 2022 +0200
+++ b/mod_rest/mod_rest.lua Thu Apr 07 17:48:08 2022 +0200
@@ -332,8 +332,10 @@
local send_type = decide_type((request.headers.accept or "") ..",".. (request.headers.content_type or ""), supported_outputs)
if echo then
+ local ret, err = errors.coerce(encode(send_type, payload));
+ if not ret then return err; end
response.headers.content_type = send_type;
- return encode(send_type, payload);
+ return ret;
end
if payload.name == "iq" then