From a3ceb27baef9490381162c206e89b7d2f67ef3c7 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Mon, 23 Apr 2012 21:34:05 +0100 Subject: mod_http: Pass portion of path that matched wildcard to wildcard handlers, as a second parameter --- plugins/mod_http.lua | 8 ++++++++ 1 file changed, 8 insertions(+) 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); -- cgit v1.2.3