local zhttp = require "resty.http"
local _M = {}
_M.__index = _M
function _M.http_post_client(url, body, timeout)
local httpc = zhttp.new()
timeout = timeout or 30000
httpc:set_timeout(timeout)
local res, err_ = httpc:request_uri(url, {
method = "POST",
body = body,
headers = {
["Content-Type"] = "application/json;charset=UTF-8",
}
})
httpc:set_keepalive(5000, 100)
httpc:close()
if not res then
return nil, err_
elseif res.status == 200 then
return res.body, err_
else
return res, err_
end
end
return _M