Software /
code /
prosody
Changeset
9376:220468f7a103
mod_http: Support global HTTP modules
Such modules simply ignore the Host header and always handle the same path.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 21 Sep 2018 23:49:56 +0200 |
parents | 9375:816591db764d |
children | 9377:f2013233e20d |
files | plugins/mod_http.lua |
diffstat | 1 files changed, 16 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_http.lua Fri Sep 21 23:40:17 2018 +0200 +++ b/plugins/mod_http.lua Fri Sep 21 23:49:56 2018 +0200 @@ -38,7 +38,11 @@ if app_path == "/" and path:sub(1,1) == "/" then app_path = ""; end - return method:upper().." "..host..app_path..path; + if host == "*" then + return method:upper().." "..app_path..path; + else + return method:upper().." "..host..app_path..path; + end end local function get_base_path(host_module, app_name, default_app_path) @@ -85,7 +89,10 @@ end function module.add_host(module) - local host = module:get_option_string("http_host", module.host); + local host = module.host; + if host ~= "*" then + host = module:get_option_string("http_host", host); + end local apps = {}; module.environment.apps = apps; local function http_app_added(event) @@ -144,12 +151,16 @@ module:handle_items("http-provider", http_app_added, http_app_removed); - server.add_host(host); - function module.unload() - server.remove_host(host); + if host ~= "*" then + server.add_host(host); + function module.unload() + server.remove_host(host); + end end end +module.add_host(module); -- set up handling on global context too + local trusted_proxies = module:get_option_set("trusted_proxies", { "127.0.0.1", "::1" })._items; local function get_ip_from_request(request)