Changeset

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
parents 9374:a1a39d395260
children 9376:220468f7a103
files net/http/server.lua
diffstat 1 files changed, 8 insertions(+), 3 deletions(-) [+]
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;