I m trying to evaluate an _expression_ is lua which is evaluated correctly. There after on condition i m calling ngx.exit(ngx.HTTP_OK). I have read about status code >= 200 should be able to abort the execution of request and status code < 200 aborting the phase_handler.
My sample location config is
location ~ /test/location/[^/]* {
default_type 'text/plain';
set $uid $1;
# Check for numeric uid
content_by_lua '
if tonumber(ngx.var.uid) == nil then
ngx.status = ngx.HTTP_GONE
ngx.say([[{"status":"ERROR", "message":"Invalid uid"}]])
ngx.exit(ngx.HTTP_OK)
end;
';
# This is only GET Endpoint
if ($request_method = GET) {
# Retrive all the projects for this UID
set $sql 'SELECT * FROM users WHERE uid = $uid ';
drizzle_query $sql;
drizzle_pass do;
rds_json on;
drizzle_connect_timeout 500ms; # default 60s
drizzle_send_query_timeout 2s; # default 60s
drizzle_recv_cols_timeout 1s; # default 60s
drizzle_recv_rows_timeout 1s; # default 60s
}
}
If i give a numeric uid it works if i give non numeric uid the lua evaluates correctly but the execution does not stop and i get sql error in drizzle.
Any suggestions.
I would also like to know how i can enable connection pool in lua_mysql module.
Thanks