comparison mod_slack_webhooks/mod_slack_webhooks.lua @ 3097:c7f4e3987ed0

mod_slack_webhooks: Fix error handling for JSON parsing util.json follows the return nil,errmsg pattern, it does not throw hard error as this code seemed to expect
author Kim Alvefur <zash@zash.se>
date Sun, 03 Jun 2018 01:34:23 +0200
parents 420391fd56e5
children 662423cea3f4
comparison
equal deleted inserted replaced
3096:420391fd56e5 3097:c7f4e3987ed0
95 local body_type = headers.content_type; 95 local body_type = headers.content_type;
96 local post_body; 96 local post_body;
97 if body_type == "application/x-www-form-urlencoded" then 97 if body_type == "application/x-www-form-urlencoded" then
98 post_body = formdecode(request.body); 98 post_body = formdecode(request.body);
99 elseif body_type == "application/json" then 99 elseif body_type == "application/json" then
100 if not pcall(function() post_body = json.decode(request.body) end) then 100 post_body = json.decode(request.body)
101 if not post_body then
101 return 420; 102 return 420;
102 end 103 end
103 else 104 else
104 return 422; 105 return 422;
105 end 106 end