aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2012-04-23 21:34:05 +0100
committerMatthew Wild <mwild1@gmail.com>2012-04-23 21:34:05 +0100
commita2e8ab35556fa6fd6591c3bf64f2f9e873b2a4f4 (patch)
treed6062fe5287c2a27cf2392ae1f75a4bb47e88ae4 /plugins
parentb19b3bb07d6d7da9ed4562945db3038214aa9baf (diff)
downloadprosody-a2e8ab35556fa6fd6591c3bf64f2f9e873b2a4f4.tar.gz
prosody-a2e8ab35556fa6fd6591c3bf64f2f9e873b2a4f4.zip
mod_http: Pass portion of path that matched wildcard to wildcard handlers, as a second parameter
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_http.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua
index cd1984c0..3dcb14d7 100644
--- a/plugins/mod_http.lua
+++ b/plugins/mod_http.lua
@@ -46,6 +46,14 @@ function module.add_host(module)
for key, handler in pairs(event.item.route or {}) do
local event_name = get_http_event(host, app_path, key);
if event_name then
+ if event_name:sub(-2, -1) == "/*" then
+ local base_path = event_name:match("/(.+)/*$");
+ local _handler = handler;
+ handler = function (event)
+ local path = event.request.path:sub(#base_path+1);
+ return _handler(event, path);
+ end;
+ end
if not app_handlers[event_name] then
app_handlers[event_name] = handler;
server.add_handler(event_name, handler);