From 19eb9076130c575a32eb25175630357a1c375917 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 21 Feb 2021 01:00:00 +0100 Subject: 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua index a13b689b..43d65b38 100644 --- a/plugins/mod_http.lua +++ b/plugins/mod_http.lua @@ -160,7 +160,13 @@ function module.add_host(module) 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+"); -- cgit v1.2.3