Skip to content

Instantly share code, notes, and snippets.

@p0pr0ck5
Created March 9, 2017 23:45
Show Gist options
  • Save p0pr0ck5/f4c58b2f9bbbe29e2b27b17a6255d3c6 to your computer and use it in GitHub Desktop.
Save p0pr0ck5/f4c58b2f9bbbe29e2b27b17a6255d3c6 to your computer and use it in GitHub Desktop.
$ cat kong/utils/public.lua
local pcall = pcall
local ngx_log = ngx.log
local ERR = ngx.ERR
local _M = {}
do
local ngx_req_get_post_args = ngx.req.get_post_args
function _M.get_post_args()
local ok, res, err = ngx_req_get_post_args()
if not ok or err then
ngx_log(ERR, "could not get body args: ", err)
return {} -- TODO return an immutable table here
end
return res
end
end
return _M
@p0pr0ck5
Copy link
Author

p0pr0ck5 commented Mar 9, 2017

bah, ignore the fact that i forgot to use pcall(...) on line 14 :|

@thibaultcha
Copy link

I think this is missing the necessary logic to either retrieve res or err as the message. That is, if we keep the if not ok or err check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment