Diff

net/http/server.lua @ 9375:816591db764d

net.http.server: Fire an event without host
author Kim Alvefur <zash@zash.se>
date Fri, 21 Sep 2018 23:40:17 +0200
parent 9338:9beb767295d4
child 9379:866cba3689f4
line wrap: on
line diff
--- a/net/http/server.lua	Sun Sep 23 17:12:21 2018 +0100
+++ b/net/http/server.lua	Fri Sep 21 23:40:17 2018 +0200
@@ -233,10 +233,15 @@
 		return;
 	end
 
-	local event = request.method.." "..host..request.path:match("[^?]*");
+	local global_event = request.method.." "..request.path:match("[^?]*");
+	local host_event = request.method.." "..host..request.path:match("[^?]*");
 	local payload = { request = request, response = response };
-	log("debug", "Firing event: %s", event);
-	local result = events.fire_event(event, payload);
+	log("debug", "Firing event: %s", global_event);
+	local result = events.fire_event(global_event, payload);
+	if result == nil then
+		log("debug", "Firing event: %s", host_event);
+		result = events.fire_event(host_event, payload);
+	end
 	if result ~= nil then
 		if result ~= true then
 			local body;