openresty / openresty/lua-nginx-module
在 nginx C module 中,如何判断是否在 openresty 环境下并且向 lua 注册 C 函数
Open
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 11.8k
- Forks
- 2.1k
- Avg merge
- 6h 1m
- Merged PRs (30d)
- 6
Description
请问在 nginx module 中,如何判断 是在 openresty 环境下,并且向 lua 注册 C 函数。
ngx_lua_foo_module:
#include <ngx_config.h>
#include <ngx_core.h>
// ... some C code running in pure nginx
// 如何判断??
#ifdef OPENRESTY
#include <lauxlib.h>
#include "ngx_http_lua_api.h"
static int
ngx_http_lua_foo_module(lua_State * L)
{
lua_createtable(L, 0, 6);
lua_pushcfunction(L, ngx_http_lua_foo);
lua_setfield(L, -2, "foo");
return 1;
}
#endif
在 编译 CONFIG 文件中 如何判断是在 openresty 环境下“
nginx compile config:
ngx_module_type=EVENT
ngx_module_name=ngx_foo_module
ngx_module_incs=
ngx_module_deps=
ngx_module_srcs=$ngx_addon_dir/ngx_foo_module.c
ngx_module_libs=
ngx_module_order=
ngx_module_link=ADDON
. auto/module
if [ "$OPENRESTY" = ”yes“ ];then # 如何判断 ??
ngx_module_type=EVENT
ngx_module_name=ngx_foo_lua_module
ngx_module_incs=
ngx_module_deps=
ngx_module_srcs=$ngx_addon_dir/ngx_foo_lua_module.c
ngx_module_libs=
ngx_module_order=
ngx_module_link=ADDON
fi
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ngx_foo_module.c and the ngx_http_lua_api.h integration shown in the issue, then inspect the nginx compile configuration around auto/module. Determine how the build detects an OpenResty environment and whether the Lua registration path can be selected safely; done requires a documented, working configuration and C integration approach.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, lua, nginx
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100