My goal is to inspect a body of the POST request and compare it to some list of key-value pairs on nginx. In my situation POST requests will always be in JSON format. Each request will contain a key:value
pair like this: "transaction":"12345"
or "transaction":"098765"
. Mean the key "transaction" will always be there and value will change some time.
I was thinking to use lua-nginx-module to inspect a post body and than compare it with key-value from let's say memcached
.
I don't have any code to show yet, but I will try to update a question, some time soon. I was wondering if someone could help me get started, with this or show how it can be done.
This is what I did:
server {
listen 80;
location /api/setdata {
lua_need_request_body on;
content_by_lua_file template/content.lua;
}
}
template/content.lua:
function processRequest()
ngx.req.read_body()
local request_body = ngx.req.get_body_data()
ngx.say(request_body)
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With