Closed chirkin closed 9 years ago
@chirkin Please use the ngx_lua module instead. It is just a single line for your use case:
rewrite_by_lua 'ngx.req.read_body()';
Simple enough. Although ngx_lua is way more powerful than just that.
@agentzh Thank you, it is really more powerful. I think the performance is not much affected.
@agentzh I found that this solution has drawbacks. In particular postgres_escape function is called before than the ngx.req.read_body() processed. I need to protect sql query. Do you have any solutions?
@chirkin Well, just use the ndk.set_var.set_quote_pgsql_str()
API function in Lua to do the escaping. You'll need the ngx_set_misc module too. See
https://github.com/openresty/lua-nginx-module#ndkset_vardirective
https://github.com/openresty/set-misc-nginx-module#set_quote_pgsql_str
@agentzh Bravo! Thank you!
In some cases, $request_body very useful, for example - send json body into database query in ngx_postgres module. Echo could fill in $request_body variable, but content phase it's too late for initialize it. Can you move this directive into rewrite phase like in "form input module"?