comparison src/luan/modules/http/Server.luan @ 1685:46cf5137cb6b

misc fixes
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 08 Jun 2022 20:13:54 -0600
parents fa066aaa068c
children b82767112d8e
comparison
equal deleted inserted replaced
1684:cfbecf7af56f 1685:46cf5137cb6b
37 dir = gsub(dir,"/$","") -- remove trailing '/' if any 37 dir = gsub(dir,"/$","") -- remove trailing '/' if any
38 Http.dir = dir 38 Http.dir = dir
39 Http.is_serving = true 39 Http.is_serving = true
40 function Io.schemes.site(path) 40 function Io.schemes.site(path)
41 local u = uri( dir..path ) 41 local u = uri( dir..path )
42 u.uri_string = "site:"..path 42 if u ~= nil then
43 u.uri_string = "site:"..path
44 end
43 return u 45 return u
44 end 46 end
45 end 47 end
46 48
47 function Server.start(server) 49 function Server.start(server)
80 local server = JavaServer.new(port,handler) 82 local server = JavaServer.new(port,handler)
81 Server.start(server) 83 Server.start(server)
82 return server, luan_handler 84 return server, luan_handler
83 end 85 end
84 86
85 function Server.serve_for_proxy(dir,port,LuanHandlerClass)
86 port = port or 8080
87 LuanHandlerClass = LuanHandlerClass or LuanHandler
88 Server.init_dir(dir)
89 local luan_handler = LuanHandlerClass.new()
90 local handler = IndexHandler.new(luan_handler)
91 handler = ContentTypeHandler.new(handler)
92 handler = SafeHandler.new(handler)
93 local server = JavaServer.new(port,handler)
94 Server.start(server)
95 return server, luan_handler
96 end
97
98 return Server 87 return Server