Hi folks
The latest git master branch of lua-nginx-module now has the new
*_by_lua_block {} directives.
For example, instead of writing
content_by_lua '
ngx.say("Hello, OpenResty\\n")
';
We can just write
content_by_lua_block {
ngx.say("Hello, OpenResty\n")
}
Note that we no longer to escape the back-slash character in the
latter form since the nginx configuration file parser now knows Lua
source (lexing) rules.
You can find more examples in the official test suite:
https://github.com/openresty/lua-nginx-module/blob/master/t/132-lua-blocks.t#L21
This feature is particularly useful for unit testing and documentation samples.
You're welcome to try out this feature out on your side and report
back any problems.
It's worth mentioning that the highly simplified Lua source lexer is
automatically generated from multiple regexes by the new DFA compiler
in sregex:
https://github.com/openresty/sregex/blob/dfa-multi-re/re.pl
We will be able to reduce the output code size when we implement the
DFA minimization algorithm in the sregex DFA compiler.
Enjoy!
-agentzh