Comparison

mod_register_json/mod_register_json.lua @ 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
parent 365:1d95b69c2c81
child 370:16da8cd69715
comparison
equal deleted inserted replaced
368:1f55e844efeb 369:29a8828243ce
104 end 104 end
105 end 105 end
106 106
107 -- Set it up! 107 -- Set it up!
108 local function setup() 108 local function setup()
109 local ports = module:get_option("reg_servlet_port") or { 9280 }; 109 local port = module:get_option("reg_servlet_port") or 9280;
110 local base_name = module:get_option("reg_servlet_base") or "register_account"; 110 local base_name = module:get_option("reg_servlet_base") or "register_account";
111 local ssl_cert = module:get_option("reg_servlet_sslcert") or false; 111 local ssl_cert = module:get_option("reg_servlet_sslcert") or false;
112 local ssl_key = module:get_option("reg_servlet_sslkey") or false; 112 local ssl_key = module:get_option("reg_servlet_sslkey") or false;
113 if not ssl_cert or not ssl_key then 113 if not ssl_cert or not ssl_key then
114 require "net.httpserver".new_from_config(ports, handle_req, { base = base_name }); 114 require "net.httpserver".new_from_config({ port = port }, handle_req, { base = base_name });
115 else 115 else
116 if module:get_option("reg_servlet_port") == nil then ports = { 9443 }; end 116 if module:get_option("reg_servlet_port") == nil then port = 9443; end
117 require "net.httpserver".new_from_config(ports, handle_req, { ssl = { key = ssl_key, certificate = ssl_cert }, base = base_name }); 117 require "net.httpserver".new_from_config({ port = port; ssl = { key = ssl_key, certificate = ssl_cert }; }, handle_req, { base = base_name });
118 end 118 end
119 end 119 end
120
120 if prosody.start_time then -- already started 121 if prosody.start_time then -- already started
121 setup(); 122 setup();
122 else 123 else
123 prosody.events.add_handler("server-started", setup); 124 prosody.events.add_handler("server-started", setup);
124 end 125 end