Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: added new API ngx.config.debug to indicate whether this is a…
… debug build of nginx.
- Loading branch information
Showing
5 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
/* | ||
* Copyright (C) Yichun Zhang (agentzh) | ||
*/ | ||
|
||
|
||
#ifndef DDEBUG | ||
#define DDEBUG 0 | ||
#endif | ||
#include "ddebug.h" | ||
|
||
|
||
#include "ngx_http_lua_config.h" | ||
|
||
|
||
void | ||
ngx_http_lua_inject_config_api(lua_State *L) | ||
{ | ||
/* ngx.config */ | ||
|
||
lua_newtable(L); /* .config */ | ||
|
||
#if (NGX_DEBUG) | ||
lua_pushboolean(L, 1); | ||
#else | ||
lua_pushboolean(L, 0); | ||
#endif | ||
|
||
lua_setfield(L, -2, "debug"); | ||
|
||
lua_setfield(L, -2, "config"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
/* | ||
* Copyright (C) Yichun Zhang (agentzh) | ||
*/ | ||
|
||
|
||
#ifndef _NGX_HTTP_LUA_CONFIG_H_INCLUDED_ | ||
#define _NGX_HTTP_LUA_CONFIG_H_INCLUDED_ | ||
|
||
|
||
#include "ngx_http_lua_common.h" | ||
|
||
|
||
void ngx_http_lua_inject_config_api(lua_State *L); | ||
|
||
|
||
#endif /* _NGX_HTTP_LUA_CONFIG_H_INCLUDED_ */ | ||
|
||
/* vi:set ft=c ts=4 sw=4 et fdm=marker: */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# vim:set ft= ts=4 sw=4 et fdm=marker: | ||
use lib 'lib'; | ||
use t::TestNginxLua; | ||
|
||
#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: ngx.config.debug | ||
--- config | ||
location /t { | ||
content_by_lua ' | ||
ngx.say("debug: ", ngx.config.debug) | ||
'; | ||
} | ||
--- request | ||
GET /t | ||
--- response_body_like chop | ||
^debug: (?:true|false)$ | ||
--- no_error_log | ||
[error] | ||