I want to check body of request to remove extra space and check Persian character.
I do this with Lua !and I say to NGINX to call it.
local string_format = string.format
ngx.req.read_body()
local body = ngx.req.get_body_data() or ""
-- Replace 'Ye' and 'Kaf' arabic char with persian
body = ngx.re.gsub(body, "ي", "ی") -- remove id and name
body = ngx.re.gsub(body, "ك", "ک") -- remove id and name
-- Remove useless space
body = ngx.re.gsub(body, " ", " ") -- remove id and name
body = ngx.re.gsub(body, '" ', '"') -- remove id and name
body = ngx.re.gsub(body, ' "', '"') -- remove id and name
ngx.req.set_body_data(body)
in above I check body and replace it with proper data and again set body.
I hope it will be help other.