Software /
code /
prosody
Comparison
plugins/mod_http.lua @ 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 |
parent | 11397:27a22a1f141c |
child | 11400:19a59cb7311e |
comparison
equal
deleted
inserted
replaced
11398:a1f26d17d70f | 11399:d5d895313be2 |
---|---|
158 end | 158 end |
159 end | 159 end |
160 | 160 |
161 local streaming = event.item.streaming_uploads; | 161 local streaming = event.item.streaming_uploads; |
162 | 162 |
163 for key, handler in pairs(event.item.route or {}) do | 163 if not event.item.route then |
164 -- TODO: Link to docs | |
165 module:log("error", "HTTP app %q provides no 'route', a typo or mistake?", app_name); | |
166 return; | |
167 end | |
168 | |
169 for key, handler in pairs(event.item.route) do | |
164 local event_name = get_http_event(host, app_path, key); | 170 local event_name = get_http_event(host, app_path, key); |
165 if event_name then | 171 if event_name then |
166 local method = event_name:match("^%S+"); | 172 local method = event_name:match("^%S+"); |
167 if not app_methods:contains(method) then | 173 if not app_methods:contains(method) then |
168 app_methods = app_methods + set.new{ method }; | 174 app_methods = app_methods + set.new{ method }; |