22 lines
385 B
Lua
22 lines
385 B
Lua
local json = require 'json'
|
|
|
|
local module = {}
|
|
|
|
module.getPostData = function()
|
|
local data, err
|
|
|
|
ngx.req.read_body()
|
|
data = ngx.req.get_body_data()
|
|
if not data then
|
|
response.quit(ngx.HTTP_BAD_REQUEST)
|
|
return
|
|
end
|
|
|
|
data, err = json.decode(data)
|
|
if err or type(data) ~= "table" then
|
|
return nil
|
|
end
|
|
return data
|
|
end
|
|
|
|
return module |