Changeset

11399:d5d895313be2

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; })
author Kim Alvefur <zash@zash.se>
date Sun, 21 Feb 2021 01:00:00 +0100
parents 11398:a1f26d17d70f
children 11400:19a59cb7311e
files plugins/mod_http.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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+");