Software /
code /
prosody-modules
Comparison
mod_rest/mod_rest.lua @ 3816:8473fd2d09c1
mod_rest: Default to replying with same type as request
If you send JSON then you get JSON back unless you say something
different with the Accept header.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 01 Jan 2020 16:40:10 +0100 |
parent | 3815:1a0a612d36bc |
child | 3821:11272a3233ce |
comparison
equal
deleted
inserted
replaced
3815:1a0a612d36bc | 3816:8473fd2d09c1 |
---|---|
100 id = payload.attr.id or id.medium(), | 100 id = payload.attr.id or id.medium(), |
101 type = payload.attr.type, | 101 type = payload.attr.type, |
102 ["xml:lang"] = payload.attr["xml:lang"], | 102 ["xml:lang"] = payload.attr["xml:lang"], |
103 }; | 103 }; |
104 module:log("debug", "Received[rest]: %s", payload:top_tag()); | 104 module:log("debug", "Received[rest]: %s", payload:top_tag()); |
105 local send_type = decide_type(request.headers.accept) | 105 local send_type = decide_type((request.headers.accept or "") ..",".. request.headers.content_type) |
106 if payload.name == "iq" then | 106 if payload.name == "iq" then |
107 if payload.attr.type ~= "get" and payload.attr.type ~= "set" then | 107 if payload.attr.type ~= "get" and payload.attr.type ~= "set" then |
108 return errors.new({ code = 422, text = "'iq' stanza must be of type 'get' or 'set'" }); | 108 return errors.new({ code = 422, text = "'iq' stanza must be of type 'get' or 'set'" }); |
109 end | 109 end |
110 return module:send_iq(payload):next( | 110 return module:send_iq(payload):next( |