From 91c5bd7853a6b40c87674399fce3a1f1f58e4754 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 21 Sep 2018 23:40:17 +0200 Subject: net.http.server: Fire an event without host --- net/http/server.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'net/http') diff --git a/net/http/server.lua b/net/http/server.lua index 877c7f17..5b42208c 100644 --- a/net/http/server.lua +++ b/net/http/server.lua @@ -233,10 +233,15 @@ function handle_request(conn, request, finish_cb) 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; -- cgit v1.2.3