Permalink
Browse files

feature: added new API function ngx.config.ngx_configure() to return …

…the NGINX ./configure arguments string to the Lua land. thanks Tatsuhiko Kubo for the patch in #339.
  • Loading branch information...
agentzh committed Mar 1, 2014
1 parent f862915 commit 441d9c28bbb364e6e9aaa03ad6d6ccb47ff07438
Showing with 47 additions and 2 deletions.
  1. +13 −1 src/ngx_http_lua_config.c
  2. +1 −1 t/062-count.t
  3. +33 −0 t/125-configure-args.t
View
@@ -15,14 +15,15 @@
static int ngx_http_lua_config_prefix(lua_State *L);
+static int ngx_http_lua_config_configure(lua_State *L);
void
ngx_http_lua_inject_config_api(lua_State *L)
{
/* ngx.config */
- lua_createtable(L, 0, 4 /* nrec */); /* .config */
+ lua_createtable(L, 0, 5 /* nrec */); /* .config */
#if (NGX_DEBUG)
lua_pushboolean(L, 1);
@@ -40,6 +41,9 @@ ngx_http_lua_inject_config_api(lua_State *L)
lua_pushinteger(L, ngx_http_lua_version);
lua_setfield(L, -2, "ngx_lua_version");
+ lua_pushcfunction(L, ngx_http_lua_config_configure);
+ lua_setfield(L, -2, "ngx_configure");
+
lua_setfield(L, -2, "config");
}
@@ -51,3 +55,11 @@ ngx_http_lua_config_prefix(lua_State *L)
ngx_cycle->prefix.len);
return 1;
}
+
+
+static int
+ngx_http_lua_config_configure(lua_State *L)
+{
+ lua_pushliteral(L, NGX_CONFIGURE);
+ return 1;
+}
View
@@ -339,7 +339,7 @@ n = 1
--- request
GET /test
--- response_body
-n = 4
+n = 5
--- no_error_log
[error]
View
@@ -0,0 +1,33 @@
+# vim:set ft= ts=4 sw=4 et fdm=marker:
+use lib 'lib';
+use Test::Nginx::Socket::Lua;
+
+#worker_connections(1014);
+#master_on();
+#workers(2);
+#log_level('warn');
+
+repeat_each(2);
+
+plan tests => repeat_each() * (blocks() * 3);
+
+#no_diff();
+#no_long_string();
+run_tests();
+
+__DATA__
+
+=== TEST 1: nginx configure
+--- config
+ location /configure_args {
+ content_by_lua '
+ ngx.say(ngx.config.ngx_configure())
+ ';
+ }
+--- request
+GET /configure_args
+--- response_body_like chop
+^\s*\-\-[^-]+
+--- no_error_log
+[error]
+

0 comments on commit 441d9c2

Please sign in to comment.