Mercurial Hosting > luan
diff src/luan/modules/http/Server.luan @ 1172:1aa6dd74f3fc
add serve_for_nginx
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 11 Feb 2018 03:19:45 -0700 |
parents | 794ddcfbee20 |
children | bdbd1d12c1f2 |
line wrap: on
line diff
--- a/src/luan/modules/http/Server.luan Sun Feb 11 02:41:23 2018 -0700 +++ b/src/luan/modules/http/Server.luan Sun Feb 11 03:19:45 2018 -0700 @@ -30,7 +30,7 @@ Server.port = 8080 -function Server.init(dir) +local function init_dir(dir) local dir_uri, dir_path if matches(dir,":") then dir_uri = dir @@ -44,6 +44,11 @@ function Io.schemes.site(path) return Io.uri( dir_uri..path ) end + return dir_path +end + +function Server.init(dir) + local dir_path = init_dir(dir) local file_handler = FileHandler.new(dir_path) local dir_handler = DirHandler.new(file_handler) local luan_handler = LuanHandler.new() @@ -75,4 +80,20 @@ Server.start() end +function Server.serve_for_nginx(dir) + init_dir(dir) + local luan_handler = LuanHandler.new() + local not_found_hander = NotFound.new(luan_handler) + local handler = luan_handler + handler = IndexHandler.new(handler) + handler = ListHandler.new( handler, not_found_hander ) + handler = ContentTypeHandler.new(handler) + handler = SafeHandler.new(handler) + handler = LogHandler.new(handler) + Server.server = JavaServer.new(Server.port,handler) + + Server.start_rpc() + Server.start() +end + return Server