moonbridge
diff example_application.lua @ 13:96b6c31d72e3
Emptied prepare method and use request:send_text_status_response(...) in example_application.lua
author | jbe |
---|---|
date | Thu Jan 29 16:53:02 2015 +0100 (2015-01-29) |
parents | 0c951f8ee92b |
children | 1fc0142c32e4 |
line diff
1.1 --- a/example_application.lua Thu Jan 29 16:34:48 2015 +0100 1.2 +++ b/example_application.lua Thu Jan 29 16:53:02 2015 +0100 1.3 @@ -3,7 +3,12 @@ 1.4 1.5 local http = require "moonbridge_http" 1.6 1.7 -local documents = {"example_webpage.html", "example_webpage.css"} 1.8 +local documents = {} 1.9 +for i, document_name in ipairs{"example_webpage.html", "example_webpage.css"} do 1.10 + local file = assert(io.open(document)) 1.11 + documents[document_name] = file:read("*a") 1.12 + file:close() 1.13 +end 1.14 1.15 listen{ 1.16 -- listen to a tcp version 4 socket 1.17 @@ -44,11 +49,6 @@ 1.18 1.19 -- preparation of process (executed after fork) 1.20 prepare = function() 1.21 - for i, document in ipairs(documents) do 1.22 - local file = assert(io.open(document)) 1.23 - documents[document] = file:read("*a") 1.24 - file:close() 1.25 - end 1.26 end, 1.27 1.28 -- connection handler 1.29 @@ -135,7 +135,7 @@ 1.30 end 1.31 1.32 else 1.33 - request:send_status("405 Method not allowed") 1.34 + request:send_text_status_response("405 Method not allowed") 1.35 1.36 end 1.37