Skip to content

Commit 20ffd85

Browse files
p0pr0ck5agentzh
authored andcommitted
feature: implemented pure C function for the pure FFI version of the ngx.get_phase() API function in lua-resty-core.
Signed-off-by: Yichun Zhang (agentzh) <agentzh@gmail.com>
1 parent b1b1504 commit 20ffd85

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/ngx_http_lua_phase.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,22 @@ ngx_http_lua_inject_phase_api(lua_State *L)
107107
lua_setfield(L, -2, "get_phase");
108108
}
109109

110+
111+
#ifndef NGX_LUA_NO_FFI_API
112+
int
113+
ngx_http_lua_ffi_get_phase(ngx_http_request_t *r, char **err)
114+
{
115+
ngx_http_lua_ctx_t *ctx;
116+
117+
ctx = ngx_http_get_module_ctx(r, ngx_http_lua_module);
118+
if (ctx == NULL) {
119+
*err = "no request context";
120+
return NGX_ERROR;
121+
}
122+
123+
return ctx->context;
124+
}
125+
#endif
126+
127+
110128
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */

0 commit comments

Comments
 (0)