comparison http/src/luan/modules/http/Server.luan @ 539:473e456444ff

Remove object-oriented primitive methods for string and binary
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 01 Jun 2015 17:53:55 -0600
parents 9bf9ad733827
children 35dde32c02ab
comparison
equal deleted inserted replaced
538:919b9410008e 539:473e456444ff
1 require "luan:String" 1 local String = require "luan:String"
2 local gsub = String.gsub
3 local match = String.match
2 local Io = require "luan:Io" 4 local Io = require "luan:Io"
3 local Package = require "luan:Package" 5 local Package = require "luan:Package"
4 local Http = require "luan:http/Http" 6 local Http = require "luan:http/Http"
5 require "luan:logging/init" -- initialize logging 7 require "luan:logging/init" -- initialize logging
6 8
70 local hc = HandlerCollection.new() 72 local hc = HandlerCollection.new()
71 hc.setHandlers { SessionHandler.new(), M.handler_wrapper, DefaultHandler.new(), M.log_handler } 73 hc.setHandlers { SessionHandler.new(), M.handler_wrapper, DefaultHandler.new(), M.log_handler }
72 74
73 75
74 function M.init(dir) 76 function M.init(dir)
75 dir = dir.gsub("/$","") -- remove trailing '/' if any 77 dir = gsub(dir,"/$","") -- remove trailing '/' if any
76 Http.dir = dir 78 Http.dir = dir
77 function Io.schemes.site(path,add_extension) 79 function Io.schemes.site(path,add_extension)
78 return Io.uri( dir..path, add_extension ) 80 return Io.uri( dir..path, add_extension )
79 end 81 end
80 M.authentication_handler.setPassword(M.private_password) 82 M.authentication_handler.setPassword(M.private_password)
81 local base = dir 83 local base = dir
82 if base.match("^classpath:") ~= nil then 84 if match(base,"^classpath:") ~= nil then
83 base = dir.."#"..M.welcome_file.."#"..M.welcome_file..".luan" 85 base = dir.."#"..M.welcome_file.."#"..M.welcome_file..".luan"
84 end 86 end
85 M.resource_handler.setResourceBase(Io.uri(base).to_string()) 87 M.resource_handler.setResourceBase(Io.uri(base).to_string())
86 M.resource_handler.setWelcomeFiles {M.welcome_file} 88 M.resource_handler.setWelcomeFiles {M.welcome_file}
87 M.luan_handler.setWelcomeFile(M.welcome_file) 89 M.luan_handler.setWelcomeFile(M.welcome_file)