Software /
code /
prosody
Comparison
plugins/mod_http.lua @ 6027:8c69cea8a1bf
Merge 0.9->0.10
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 26 Feb 2014 22:21:55 +0100 |
parent | 5776:bd0ff8ae98a8 |
parent | 6026:8a8be471ec72 |
child | 6086:3b4fde51fa25 |
comparison
equal
deleted
inserted
replaced
6021:f8c17af769d9 | 6027:8c69cea8a1bf |
---|---|
40 | 40 |
41 local function get_base_path(host_module, app_name, default_app_path) | 41 local function get_base_path(host_module, app_name, default_app_path) |
42 return (normalize_path(host_module:get_option("http_paths", {})[app_name] -- Host | 42 return (normalize_path(host_module:get_option("http_paths", {})[app_name] -- Host |
43 or module:get_option("http_paths", {})[app_name] -- Global | 43 or module:get_option("http_paths", {})[app_name] -- Global |
44 or default_app_path)) -- Default | 44 or default_app_path)) -- Default |
45 :gsub("%$(%w+)", { host = module.host }); | 45 :gsub("%$(%w+)", { host = host_module.host }); |
46 end | 46 end |
47 | 47 |
48 local ports_by_scheme = { http = 80, https = 443, }; | 48 local ports_by_scheme = { http = 80, https = 443, }; |
49 | 49 |
50 -- Helper to deduce a module's external URL | 50 -- Helper to deduce a module's external URL |
51 function moduleapi.http_url(module, app_name, default_path) | 51 function moduleapi.http_url(module, app_name, default_path) |
52 app_name = app_name or (module.name:gsub("^http_", "")); | 52 app_name = app_name or (module.name:gsub("^http_", "")); |
53 local external_url = url_parse(module:get_option_string("http_external_url")) or {}; | 53 local external_url = url_parse(module:get_option_string("http_external_url")) or {}; |
54 if external_url.scheme and external_url.port == nil then | |
55 external_url.port = ports_by_scheme[external_url.scheme]; | |
56 end | |
54 local services = portmanager.get_active_services(); | 57 local services = portmanager.get_active_services(); |
55 local http_services = services:get("https") or services:get("http") or {}; | 58 local http_services = services:get("https") or services:get("http") or {}; |
56 for interface, ports in pairs(http_services) do | 59 for interface, ports in pairs(http_services) do |
57 for port, services in pairs(ports) do | 60 for port, services in pairs(ports) do |
58 local url = { | 61 local url = { |