Comparison

plugins/mod_http.lua @ 5183:8461e8ed7c09

mod_http: Rename variable for clarity
author Matthew Wild <mwild1@gmail.com>
date Thu, 22 Nov 2012 17:38:53 +0000
parent 5180:4ef69555a879
child 5190:76c73bd3d483
comparison
equal deleted inserted replaced
5181:1e9508ae44cc 5183:8461e8ed7c09
46 local ports_by_scheme = { http = 80, https = 443, }; 46 local ports_by_scheme = { http = 80, https = 443, };
47 47
48 -- Helper to deduce a module's external URL 48 -- Helper to deduce a module's external URL
49 function moduleapi.http_url(module, app_name, default_path) 49 function moduleapi.http_url(module, app_name, default_path)
50 app_name = app_name or (module.name:gsub("^http_", "")); 50 app_name = app_name or (module.name:gsub("^http_", ""));
51 local ext = url_parse(module:get_option_string("http_external_url")) or {}; 51 local external_url = url_parse(module:get_option_string("http_external_url")) or {};
52 local services = portmanager.get_active_services(); 52 local services = portmanager.get_active_services();
53 local http_services = services:get("https") or services:get("http") or {}; 53 local http_services = services:get("https") or services:get("http") or {};
54 for interface, ports in pairs(http_services) do 54 for interface, ports in pairs(http_services) do
55 for port, services in pairs(ports) do 55 for port, services in pairs(ports) do
56 local url = { 56 local url = {
57 scheme = (ext.scheme or services[1].service.name); 57 scheme = (external_url.scheme or services[1].service.name);
58 host = (ext.host or module.host); 58 host = (external_url.host or module.host);
59 port = tonumber(ext.port) or port or 80; 59 port = tonumber(external_url.port) or port or 80;
60 path = normalize_path(ext.path or "/").. 60 path = normalize_path(external_url.path or "/")..
61 (get_base_path(module, app_name, default_path or "/"..app_name):sub(2)); 61 (get_base_path(module, app_name, default_path or "/"..app_name):sub(2));
62 } 62 }
63 if ports_by_scheme[url.scheme] == url.port then url.port = nil end 63 if ports_by_scheme[url.scheme] == url.port then url.port = nil end
64 return url_build(url); 64 return url_build(url);
65 end 65 end