plugins/mod_http.lua
changeset 4915 3fbc01d1fc5a
parent 4911 4c8575b09ff6
child 5092 a89f8f2f2943
equal deleted inserted replaced
4914:2e9b16b2ae00 4915:3fbc01d1fc5a
    42 -- Helper to deduce a module's external URL
    42 -- Helper to deduce a module's external URL
    43 function moduleapi.http_url(module, app_name, default_path)
    43 function moduleapi.http_url(module, app_name, default_path)
    44 	app_name = app_name or (module.name:gsub("^http_", ""));
    44 	app_name = app_name or (module.name:gsub("^http_", ""));
    45 	local ext = url_parse(module:get_option_string("http_external_url")) or {};
    45 	local ext = url_parse(module:get_option_string("http_external_url")) or {};
    46 	local services = portmanager.get_active_services();
    46 	local services = portmanager.get_active_services();
    47 	local http_services = services:get("https") or services:get("http");
    47 	local http_services = services:get("https") or services:get("http") or {};
    48 	for interface, ports in pairs(http_services) do
    48 	for interface, ports in pairs(http_services) do
    49 		for port, services in pairs(ports) do
    49 		for port, services in pairs(ports) do
    50 			local path = get_base_path(module, app_name, default_path or "/"..app_name);
    50 			local path = get_base_path(module, app_name, default_path or "/"..app_name);
    51 			port = tonumber(ext.port) or port or 80;
    51 			port = tonumber(ext.port) or port or 80;
    52 			if port == 80 then port = ""; else port = ":"..port; end
    52 			if port == 80 then port = ""; else port = ":"..port; end