mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
git-subtree-dir: src/deps/src/lua-resty-core git-subtree-split: 31fae862a1ed64033591f991fadb0dd80358ba0b
29 lines
769 B
Lua
29 lines
769 B
Lua
local base = require "resty.core.base"
|
|
local get_request = base.get_request
|
|
|
|
do
|
|
local keys = {'create', 'yield', 'resume', 'status', 'wrap'}
|
|
local errmsg = base.get_errmsg_ptr()
|
|
local get_raw_phase = ngx.get_raw_phase
|
|
|
|
for _, key in ipairs(keys) do
|
|
local std = coroutine['_' .. key]
|
|
local ours = coroutine['__' .. key]
|
|
coroutine[key] = function (...)
|
|
local r = get_request()
|
|
if r ~= nil then
|
|
local ctx = get_raw_phase(r, errmsg)
|
|
if ctx ~= 0x020 and ctx ~= 0x040 then
|
|
return ours(...)
|
|
end
|
|
end
|
|
return std(...)
|
|
end
|
|
end
|
|
|
|
package.loaded.coroutine = coroutine
|
|
end
|
|
|
|
return {
|
|
version = base.version
|
|
}
|