Comparison

net/httpserver.lua @ 1868:36e1238db2f2

net.httpserver: Allow modules registering to provide more than just a default path when using httpserver.new_from_config
author Matthew Wild <mwild1@gmail.com>
date Sat, 03 Oct 2009 00:54:58 +0100
parent 1666:d1243b321c45
child 2021:43b7c0980d23
comparison
equal deleted inserted replaced
1867:57446ab8806f 1868:36e1238db2f2
250 250
251 function set_default_handler(handler) 251 function set_default_handler(handler)
252 default_handler = handler; 252 default_handler = handler;
253 end 253 end
254 254
255 function new_from_config(ports, default_base, handle_request) 255 function new_from_config(ports, handle_request, default_options)
256 if type(handle_request) == "string" then -- COMPAT with old plugins
257 log("warn", "Old syntax of httpserver.new_from_config being used to register %s", handle_request);
258 handle_request, default_options = default_options, { base = handle_request };
259 end
256 for _, options in ipairs(ports) do 260 for _, options in ipairs(ports) do
257 local port, base, ssl, interface = 5280, default_base, false, nil; 261 local port = default_options.port or 5280;
262 local base = default_options.base;
263 local ssl = default_options.ssl or false;
264 local interface = default_options.interface;
258 if type(options) == "number" then 265 if type(options) == "number" then
259 port = options; 266 port = options;
260 elseif type(options) == "table" then 267 elseif type(options) == "table" then
261 port, base, ssl, interface = options.port or 5280, options.path or default_base, options.ssl or false, options.interface; 268 port = options.port or port;
269 base = options.path or base;
270 ssl = options.ssl or ssl;
271 interface = options.interface or interface;
262 elseif type(options) == "string" then 272 elseif type(options) == "string" then
263 base = options; 273 base = options;
264 end 274 end
265 275
266 if ssl then 276 if ssl then