Mercurial Hosting > luan
changeset 1173:bdbd1d12c1f2
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 11 Feb 2018 16:31:02 -0700 |
parents | 1aa6dd74f3fc |
children | bdf27aa2a65c |
files | src/luan/modules/http/Server.luan |
diffstat | 1 files changed, 14 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/modules/http/Server.luan Sun Feb 11 03:19:45 2018 -0700 +++ b/src/luan/modules/http/Server.luan Sun Feb 11 16:31:02 2018 -0700 @@ -47,7 +47,17 @@ return dir_path end -function Server.init(dir) +local function start(handler) + function Rpc.functions.call(domain,fn_name,...) + return Server.luan_handler.call_rpc(fn_name,...) + end + Thread.fork(Rpc.serve) + + Server.server = JavaServer.new(Server.port,handler) + LuanHandler.start(Server.server) +end + +function Server.serve(dir) local dir_path = init_dir(dir) local file_handler = FileHandler.new(dir_path) local dir_handler = DirHandler.new(file_handler) @@ -55,29 +65,11 @@ local not_found_hander = NotFound.new(luan_handler) local handler = ListHandler.new( luan_handler, file_handler ) handler = IndexHandler.new(handler) - handler = ListHandler.new( handler, dir_handler, not_found_hander ) + handler = ListHandler.new( handler, not_found_hander, dir_handler ) handler = ContentTypeHandler.new(handler) handler = SafeHandler.new(handler) handler = LogHandler.new(handler) - Server.server = JavaServer.new(Server.port,handler) -end - -function Server.start() - LuanHandler.start(Server.server) -end - -function Server.start_rpc() - function Rpc.functions.call(domain,fn_name,...) - return Server.luan_handler.call_rpc(fn_name,...) - end - - Thread.fork(Rpc.serve) -end - -function Server.serve(dir) - Server.init(dir) - Server.start_rpc() - Server.start() + start(handler) end function Server.serve_for_nginx(dir) @@ -90,10 +82,7 @@ handler = ContentTypeHandler.new(handler) handler = SafeHandler.new(handler) handler = LogHandler.new(handler) - Server.server = JavaServer.new(Server.port,handler) - - Server.start_rpc() - Server.start() + start(handler) end return Server