diff options
author | Matthew Wild <mwild1@gmail.com> | 2012-04-23 18:23:49 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2012-04-23 18:23:49 +0100 |
commit | ead2ecb05d1867fc2f4e7a5d76ba4052205a6a23 (patch) | |
tree | e04761a55a6af8edf4aad4fdc6bdc8612af26a47 /plugins/mod_http.lua | |
parent | 78051fedaca3cff787f530aa9cab17d719393a79 (diff) | |
download | prosody-ead2ecb05d1867fc2f4e7a5d76ba4052205a6a23.tar.gz prosody-ead2ecb05d1867fc2f4e7a5d76ba4052205a6a23.zip |
mod_http: Support for default_path in apps
Diffstat (limited to 'plugins/mod_http.lua')
-rw-r--r-- | plugins/mod_http.lua | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua index d8e1e10a..cd1984c0 100644 --- a/plugins/mod_http.lua +++ b/plugins/mod_http.lua @@ -17,7 +17,7 @@ local function normalize_path(path) return path; end -local function get_http_event(http_module, app_name, key) +local function get_http_event(host, app_path, key) local method, path = key:match("^(%S+)%s+(.+)$"); if not method and key:sub(1,1) == "/" then method, path = "GET", key; @@ -25,15 +25,17 @@ local function get_http_event(http_module, app_name, key) return nil; end path = normalize_path(path); - local app_path = normalize_path(http_module:get_option_string(app_name.."_http_path", "/"..app_name)); - return method:upper().." "..http_module.host..app_path..path; + return method:upper().." "..host..app_path..path; end function module.add_host(module) + local host = module.host; local apps = {}; module.environment.apps = apps; local function http_app_added(event) local app_name = event.item.name; + local default_app_path = event.item.default_path or "/"..app_name; + local app_path = normalize_path(module:get_option_string(app_name.."_http_path", default_app_path)); if not app_name then -- TODO: Link to docs module:log("error", "HTTP app has no 'name', add one or use module:provides('http', app)"); @@ -42,7 +44,7 @@ function module.add_host(module) apps[app_name] = apps[app_name] or {}; local app_handlers = apps[app_name]; for key, handler in pairs(event.item.route or {}) do - local event_name = get_http_event(module, app_name, key); + local event_name = get_http_event(host, app_path, key); if event_name then if not app_handlers[event_name] then app_handlers[event_name] = handler; |