diff options
author | Kim Alvefur <zash@zash.se> | 2014-11-09 20:32:33 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2014-11-09 20:32:33 +0100 |
commit | 639527b16590d9032d4340c5e6570909c6cdc776 (patch) | |
tree | 00a4652d294babdf3be6f9add9a811a0e180a5d8 /plugins/mod_http.lua | |
parent | cebfb0bf3e29df5aac96cb0d41adb8e356921dc8 (diff) | |
parent | 61b8eb49edf8e9a2d1ae2d55a898fc6e69a6f59e (diff) | |
download | prosody-639527b16590d9032d4340c5e6570909c6cdc776.tar.gz prosody-639527b16590d9032d4340c5e6570909c6cdc776.zip |
Merge 0.10->trunk
Diffstat (limited to 'plugins/mod_http.lua')
-rw-r--r-- | plugins/mod_http.lua | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/plugins/mod_http.lua b/plugins/mod_http.lua index 49529ea2..8bda1cac 100644 --- a/plugins/mod_http.lua +++ b/plugins/mod_http.lua @@ -45,6 +45,11 @@ local function get_base_path(host_module, app_name, default_app_path) :gsub("%$(%w+)", { host = host_module.host }); end +local function redir_handler(event) + event.response.headers.location = event.request.path.."/"; + return 301; +end + local ports_by_scheme = { http = 80, https = 443, }; -- Helper to deduce a module's external URL @@ -99,6 +104,9 @@ function module.add_host(module) local path = event.request.path:sub(base_path_len); return _handler(event, path); end; + module:hook_object_event(server, event_name:sub(1, -3), redir_handler, -1); + elseif event_name:sub(-1, -1) == "/" then + module:hook_object_event(server, event_name:sub(1, -2), redir_handler, -1); end if not app_handlers[event_name] then app_handlers[event_name] = handler; |