# HG changeset patch # User jbe # Date 1422614712 -3600 # Node ID 19a6d18bf34ec88d41e51e13af7d5ffa9bb59e65 # Parent 2916ad931f7e6f6d25415eefa5aed231fafc7c18 Added some comments to example_application.lua diff -r 2916ad931f7e -r 19a6d18bf34e example_application.lua --- a/example_application.lua Fri Jan 30 00:27:28 2015 +0100 +++ b/example_application.lua Fri Jan 30 11:45:12 2015 +0100 @@ -3,10 +3,11 @@ local http = require "moonbridge_http" +-- preparation before forking: local documents = {} for i, document_name in ipairs{"example_webpage.html", "example_webpage.css"} do local file = assert(io.open(document_name)) - documents[document_name] = file:read("*a") + documents[document_name] = file:read("*a") -- store file contents in memory file:close() end @@ -49,6 +50,7 @@ -- preparation of process (executed after fork) prepare = function() + -- e.g. open database connection end, -- connection handler @@ -77,10 +79,9 @@ else local document_name = request.path local document_extension = string.match(document_name, "%.([^.])$") - local document = documents[document_name] + local document = documents[document_name] -- loads file contents from memory if document then request:send_status("200 OK") - if document_extension == "html" then request:send_header("Content-Type", "text/html; charset=UTF-8") elseif document_extension == "css" then @@ -151,6 +152,7 @@ -- executed on process termination finish = function() + -- e.g. close database connection end }