plugins/mod_http.lua
changeset 6605 61b6a4fc65f1
parent 6586 93bab6958683
parent 6601 4b4852c4f96a
child 6967 ed5440a6ef7f
child 7584 01d0d466d7be
equal deleted inserted replaced
6590:54306208f30b 6605:61b6a4fc65f1
    72 			}
    72 			}
    73 			if ports_by_scheme[url.scheme] == url.port then url.port = nil end
    73 			if ports_by_scheme[url.scheme] == url.port then url.port = nil end
    74 			return url_build(url);
    74 			return url_build(url);
    75 		end
    75 		end
    76 	end
    76 	end
       
    77 	module:log("warn", "No http ports enabled, can't generate an external URL");
       
    78 	return "http://disabled.invalid/";
    77 end
    79 end
    78 
    80 
    79 function module.add_host(module)
    81 function module.add_host(module)
    80 	local host = module:get_option_string("http_host", module.host);
    82 	local host = module:get_option_string("http_host", module.host);
    81 	local apps = {};
    83 	local apps = {};
   116 				end
   118 				end
   117 			else
   119 			else
   118 				module:log("error", "Invalid route in %s, %q. See http://prosody.im/doc/developers/http#routes", app_name, key);
   120 				module:log("error", "Invalid route in %s, %q. See http://prosody.im/doc/developers/http#routes", app_name, key);
   119 			end
   121 			end
   120 		end
   122 		end
       
   123 		local services = portmanager.get_active_services();
       
   124 		if services:get("https") or services:get("http") then
       
   125 			module:log("debug", "Serving '%s' at %s", app_name, module:http_url(app_name, app_path));
       
   126 		else
       
   127 			module:log("warn", "Not listening on any ports, '%s' will be unreachable", app_name);
       
   128 		end
   121 	end
   129 	end
   122 
   130 
   123 	local function http_app_removed(event)
   131 	local function http_app_removed(event)
   124 		local app_handlers = apps[event.item.name];
   132 		local app_handlers = apps[event.item.name];
   125 		apps[event.item.name] = nil;
   133 		apps[event.item.name] = nil;