语法: content_by_lua <lua-script-str>
环境: location, location if
阶段: content
作为"内容处理程序",为每一个请求执行<lua-script-str>
中指定的Lua代码。
这些 Lua 代码可以调用全部 API,并作为一个新的协程,在一个独立的全局环境中执行(就像一个沙盒)。
不要将本指令和其他内容处理程序指令放到同一个location中。 比如,本指令和proxy_pass指令就不能在同一个location中使用。
English Source
syntax: content_by_lua <lua-script-str>
context: location, location if
phase: content
Acts as a "content handler" and executes Lua code string specified in <lua-script-str>
for every request.
The Lua code may make API calls and is executed as a new spawned coroutine in an independent global environment (i.e. a sandbox).
Do not use this directive and other content handler directives in the same location. For example, this directive and the proxy_pass directive should not be used in the same location.