示例工程 32-openresty-and-redis
32-openresty-and-redis/01-ngx-handler/README.md
# 01 · ngx-handler
**演示**:把 `ngx` 作为参数传入,用 stub 测试 handler 逻辑。
**运行时**:`lua54`(stub;真实 OpenResty 为 🖐)。
**运行**:
```sh
.tools/bin/lua54 scripts/run-example.lua examples/32-openresty-and-redis/01-ngx-handler
.tools/bin/lua54 scripts/test-example.lua examples/32-openresty-and-redis/01-ngx-handler
```
**预期输出**(lua 5.4.9 / macOS arm64):
```text
status=200 body=hello Ada
```
**看点**:逻辑与宿主解耦,才能在普通 Lua 里测试。
**注意**:🖐 真实环境用 `content_by_lua_block`,`ngx.var.arg_name` 来自查询串。