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;
})
--- 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+");