mod_http: Warn if app is missing 'route'
authorKim Alvefur <zash@zash.se>
Sun, 21 Feb 2021 01:00:00 +0100
changeset 11403 d5d895313be2
parent 11402 a1f26d17d70f
child 11404 19a59cb7311e
mod_http: Warn if app is missing 'route' Makes no sense to have a http module with no handlers Would have helped me when I accidentally module:provides("http", { GET = handler; })
plugins/mod_http.lua
--- a/plugins/mod_http.lua	Tue Feb 23 02:56:49 2021 +0100
+++ b/plugins/mod_http.lua	Sun Feb 21 01:00:00 2021 +0100
@@ -160,7 +160,13 @@
 
 		local streaming = event.item.streaming_uploads;
 
-		for key, handler in pairs(event.item.route or {}) do
+		if not event.item.route then
+			-- TODO: Link to docs
+			module:log("error", "HTTP app %q provides no 'route', a typo or mistake?", app_name);
+			return;
+		end
+
+		for key, handler in pairs(event.item.route) do
 			local event_name = get_http_event(host, app_path, key);
 			if event_name then
 				local method = event_name:match("^%S+");