comparison mod_rest/mod_rest.lua @ 4988:732229fe68ab

mod_rest: Fill in 'type' field in error registry The 'type' defaults to "modify" in util.error, which doesn't quite fit many of these error conditions. LuaFormatter changed ',' to ';'
author Kim Alvefur <zash@zash.se>
date Mon, 15 Aug 2022 15:26:14 +0200
parents 537054999093
children cb19cb1c03d6
comparison
equal deleted inserted replaced
4987:8a8ec909ac20 4988:732229fe68ab
260 end 260 end
261 error "unsupported encoding"; 261 error "unsupported encoding";
262 end 262 end
263 263
264 local post_errors = errors.init("mod_rest", { 264 local post_errors = errors.init("mod_rest", {
265 noauthz = { code = 401, type = "auth", condition = "not-authorized", text = "No credentials provided" }, 265 noauthz = { code = 401; type = "auth"; condition = "not-authorized"; text = "No credentials provided" };
266 unauthz = { code = 403, type = "auth", condition = "not-authorized", text = "Credentials not accepted" }, 266 unauthz = { code = 403; type = "auth"; condition = "not-authorized"; text = "Credentials not accepted" };
267 parse = { code = 400, condition = "not-well-formed", text = "Failed to parse payload", }, 267 parse = { code = 400; type = "modify"; condition = "not-well-formed"; text = "Failed to parse payload" };
268 xmlns = { code = 422, condition = "invalid-namespace", text = "'xmlns' attribute must be empty", }, 268 xmlns = { code = 422; type = "modify"; condition = "invalid-namespace"; text = "'xmlns' attribute must be empty" };
269 name = { code = 422, condition = "unsupported-stanza-type", text = "Invalid stanza, must be 'message', 'presence' or 'iq'.", }, 269 name = { code = 422; type = "modify"; condition = "unsupported-stanza-type"; text = "Invalid stanza, must be 'message', 'presence' or 'iq'." };
270 to = { code = 422, condition = "improper-addressing", text = "Invalid destination JID", }, 270 to = { code = 422; type = "modify"; condition = "improper-addressing"; text = "Invalid destination JID" };
271 from = { code = 422, condition = "invalid-from", text = "Invalid source JID", }, 271 from = { code = 422; type = "modify"; condition = "invalid-from"; text = "Invalid source JID" };
272 from_auth = { code = 403, condition = "not-authorized", text = "Not authorized to send stanza with requested 'from'", }, 272 from_auth = { code = 403; type = "auth"; condition = "not-authorized"; text = "Not authorized to send stanza with requested 'from'" };
273 iq_type = { code = 422, condition = "invalid-xml", text = "'iq' stanza must be of type 'get' or 'set'", }, 273 iq_type = { code = 422; type = "modify"; condition = "invalid-xml"; text = "'iq' stanza must be of type 'get' or 'set'" };
274 iq_tags = { code = 422, condition = "bad-format", text = "'iq' stanza must have exactly one child tag", }, 274 iq_tags = { code = 422; type = "modify"; condition = "bad-format"; text = "'iq' stanza must have exactly one child tag" };
275 mediatype = { code = 415, condition = "bad-format", text = "Unsupported media type" }, 275 mediatype = { code = 415; type = "cancel"; condition = "bad-format"; text = "Unsupported media type" };
276 }); 276 });
277 277
278 -- GET → iq-get 278 -- GET → iq-get
279 local function parse_request(request, path) 279 local function parse_request(request, path)
280 if path and request.method == "GET" then 280 if path and request.method == "GET" then