I'm trying to show HEADER.html before response and FOOTER.html after response. (Example:
http {
server {
listen 8080;
root /var/www/html;
index index.html;
autoindex on;
location ~ 1/$ {
default_type text/html;
content_by_lua_block {
-- ------------------------------------------------------
function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
function readAll(file)
local f = io.open(file, "rb")
local content = f:read("*all")
f:close()
return content
end
function try_say(fname)
if file_exists(fname) then
ngx.say(readAll(fname))
end
end
local pref = ngx.var.document_root .. ngx.var.uri
try_say(pref .. "HEADER.html")
-- local res = ngx.location.capture(ngx.var.uri .. '?nolua=1')
-- ??????? ngx.say(show_current_page_without_lua()) ???????
try_say(pref .. "FOOTER.html")
-- --------------------------------------------------------
}
}
}
}
I'm stuck to show origin page... Are there any possible way to implement it?