After calling proxy_pass, I want to store the result into a session
using resty-session.
To to that I'm using the
ngx.timer.at workaround.
Here is what my code look like...
proxy_pass
http://someserver;
header_filter_by_lua_block {
local function saveProfile(premature, profileJSON)
if premature then
return
end
local profile = require("cjson").decode(profileJSON)
local session = require "resty.session".start{ secret =
secret }
for key, val in pairs(profile) do
session.data[key] = val
end
session:save()
end
local profileJSON = ngx.resp.get_headers()['profile']
if profileJSON then
ngx.timer.at(0, saveProfile, profileJSON)
end
}
There error I'm getting is this...
2016/04/19 01:24:34 [error] 55#55: lua entry thread aborted: runtime
error:
/usr/local/openresty/luajit/share/lua/5.1/resty/session.lua:223: API
disabled in the current context
stack traceback:
coroutine 0:
[C]: in function '__index'
/usr/local/openresty/luajit/share/lua/5.1/resty/session.lua:223:
in function 'open'
/usr/local/openresty/luajit/share/lua/5.1/resty/session.lua:285:
in function 'start'
header_filter_by_lua:11: in function
<header_filter_by_lua:3>, context: ngx.timer, client:
192.168.1.175, server:
0.0.0.0:443
Question is, am I not using the
ngx.timer.at workaround correctly?
Or is this a problem with resty-session?
Thank you for your help.
--ming