1
0
forked from Tank/braga
braga/framework/hook.lua
2026-03-08 15:29:51 +04:00

38 lines
810 B
Lua

local _M = {}
local json = require('cjson.safe')
local http = require("resty.http").new()
-- отправка запроса по https
local function req(url,body)
local res, err = http:request_uri(url, {
method = "POST",
body = body,
headers = {
["Content-Type"] = "application/x-www-form-urlencoded",
},
})
if not res then
ngx.log(ngx.INFO, "Ошибка отправки хука: ", err)
return false
end
local status = res.status
if status == 200 then
ngx.log(ngx.INFO, 'Хук отправлен: '..url..' | '..body..': '..status)
ngx.say(body)
return true
else
ngx.log(ngx.INFO, 'Ошибка отправки хука (ответ получателя не 200): '..url..' | '..body..': '..status)
return false
end
end
return _M