Hi I am new to lua and nginx and wondering if the site example below is the best way of achieving what I want to do as a learning exercise ?
I plan to use a shell script which would output a value into a file i.e. /version/latest.html which contents say v1.0.0
then when the location /check it looks for value in /version/latest.html and uses lua to print it out
site example
# transparent non-blocking I/O in Lua via subrequests
location /lua {
# MIME type determined by default_type:
default_type 'text/plain';
content_by_lua '
local res = ngx.location.capture("/some_other_location")
if res.status == 200 then
ngx.print(res.body)
end';
}
so my example would be ?
# transparent non-blocking I/O in Lua via subrequests
location /check {
# MIME type determined by default_type:
default_type 'text/plain';
content_by_lua '
local res = ngx.location.capture("/version/latest.html")
if res.status == 200 then
ngx.print(res.body)
end';
}
best way of doing such with lua ?
thanks
George