Changeset

369:29a8828243ce

mod_register_json: Fixed http listener creation syntax. (Please document that in the API, that would avoid my brain overheating, thank you.)
author Marco Cirillo <maranda@lightwitch.org>
date Thu, 21 Apr 2011 21:36:58 +0000
parents 368:1f55e844efeb
children 370:16da8cd69715
files mod_register_json/mod_register_json.lua
diffstat 1 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mod_register_json/mod_register_json.lua	Sun Apr 17 14:52:20 2011 +0000
+++ b/mod_register_json/mod_register_json.lua	Thu Apr 21 21:36:58 2011 +0000
@@ -106,19 +106,20 @@
 
 -- Set it up!
 local function setup()
-        local ports = module:get_option("reg_servlet_port") or { 9280 };
-        local base_name = module:get_option("reg_servlet_base") or "register_account";
-        local ssl_cert = module:get_option("reg_servlet_sslcert") or false;
-        local ssl_key = module:get_option("reg_servlet_sslkey") or false;
-        if not ssl_cert or not ssl_key then
-        	require "net.httpserver".new_from_config(ports, handle_req, { base = base_name });
-        else
-        	if module:get_option("reg_servlet_port") == nil then ports = { 9443 }; end
-        	require "net.httpserver".new_from_config(ports, handle_req, { ssl = { key = ssl_key, certificate = ssl_cert }, base = base_name });
+	local port = module:get_option("reg_servlet_port") or 9280;
+	local base_name = module:get_option("reg_servlet_base") or "register_account";
+	local ssl_cert = module:get_option("reg_servlet_sslcert") or false;
+	local ssl_key = module:get_option("reg_servlet_sslkey") or false;
+	if not ssl_cert or not ssl_key then
+		require "net.httpserver".new_from_config({ port = port }, handle_req, { base = base_name });
+	else
+		if module:get_option("reg_servlet_port") == nil then port = 9443; end
+		require "net.httpserver".new_from_config({ port = port; ssl = { key = ssl_key, certificate = ssl_cert }; }, handle_req, { base = base_name });
 	end
 end
+
 if prosody.start_time then -- already started
-        setup();
+	setup();
 else
-        prosody.events.add_handler("server-started", setup);
+	prosody.events.add_handler("server-started", setup);
 end