Comparison

mod_pubsub_github/mod_pubsub_github.lua @ 3263:a65f4297264b

mod_pubsub_github: Unpack request from event
author Kim Alvefur <zash@zash.se>
date Fri, 24 Aug 2018 17:46:47 +0200
parent 1620:754d97ba333d
child 3264:f48bedd1d433
comparison
equal deleted inserted replaced
3262:0ccdd3f31435 3263:a65f4297264b
6 6
7 local pubsub_service = module:depends("pubsub").service; 7 local pubsub_service = module:depends("pubsub").service;
8 local node = module:get_option("github_node", "github"); 8 local node = module:get_option("github_node", "github");
9 9
10 function handle_POST(event) 10 function handle_POST(event)
11 local data = json.decode(event.request.body); 11 local request = event.request;
12 local data = json.decode(request.body);
12 if not data then 13 if not data then
13 return "Invalid JSON. From you of all people..."; 14 return "Invalid JSON. From you of all people...";
14 end 15 end
15 16
16 for _, commit in ipairs(data.commits) do 17 for _, commit in ipairs(data.commits) do
26 :tag("email"):text(commit.author.email):up() 27 :tag("email"):text(commit.author.email):up()
27 :up() 28 :up()
28 ); 29 );
29 end 30 end
30 31
31 module:log("debug", "Handled POST: \n%s\n", tostring(event.request.body)); 32 module:log("debug", "Handled POST: \n%s\n", tostring(request.body));
32 return "Thank you Github!"; 33 return "Thank you Github!";
33 end 34 end
34 35
35 module:provides("http", { 36 module:provides("http", {
36 route = { 37 route = {