Mercurial Hosting > luan
diff src/luan/modules/http/Server.luan @ 1315:5763597ca5c0
add DomainHandler
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 30 Jan 2019 01:21:49 -0700 |
parents | 51a1987b55a3 |
children | 643cf1c37723 |
line wrap: on
line diff
--- a/src/luan/modules/http/Server.luan Tue Jan 29 19:10:39 2019 -0700 +++ b/src/luan/modules/http/Server.luan Wed Jan 30 01:21:49 2019 -0700 @@ -6,6 +6,7 @@ local matches = String.matches or error() local try = Luan.try or error() local Io = require "luan:Io.luan" +local uri = Io.uri or error() local Package = require "luan:Package.luan" local Rpc = require "luan:Rpc.luan" local Thread = require "luan:Thread.luan" @@ -35,7 +36,7 @@ dir = gsub(dir,"/$","") -- remove trailing '/' if any Http.dir = dir function Io.schemes.site(path) - return Io.uri( dir..path ) + return uri( dir..path ) end end @@ -77,10 +78,11 @@ return server, luan_handler end -function Server.serve_for_proxy(dir,port) +function Server.serve_for_proxy(dir,port,LuanHandlerClass) port = port or 8080 + LuanHandlerClass = LuanHandlerClass or LuanHandler Server.init_dir(dir) - local luan_handler = LuanHandler.new() + local luan_handler = LuanHandlerClass.new() local handler = IndexHandler.new(luan_handler) handler = ContentTypeHandler.new(handler) handler = SafeHandler.new(handler)