change var name and add description

This commit is contained in:
Karol Wypchlo 2022-01-07 13:36:04 +01:00
parent d24c677a30
commit 31b7090863
No known key found for this signature in database
GPG Key ID: B515DE9EEBE241E1
1 changed files with 6 additions and 3 deletions

View File

@ -6,16 +6,19 @@ log_by_lua_block {
if premature then return end if premature then return end
local httpc = require("resty.http").new() local httpc = require("resty.http").new()
local method = request_method == "GET" and "read" or "write"
-- based on request method we assign a registry action string used
-- in track endpoint namely "read" for GET and "write" for POST
local registry_action = request_method == "GET" and "read" or "write"
-- 10.10.10.70 points to accounts service (alias not available when using resty-http) -- 10.10.10.70 points to accounts service (alias not available when using resty-http)
local res, err = httpc:request_uri("http://10.10.10.70:3000/track/registry/" .. method, { local res, err = httpc:request_uri("http://10.10.10.70:3000/track/registry/" .. registry_action, {
method = "POST", method = "POST",
headers = { ["Cookie"] = "skynet-jwt=" .. jwt }, headers = { ["Cookie"] = "skynet-jwt=" .. jwt },
}) })
if err or (res and res.status ~= ngx.HTTP_NO_CONTENT) then if err or (res and res.status ~= ngx.HTTP_NO_CONTENT) then
ngx.log(ngx.ERR, "Failed accounts service request /track/registry/" .. method .. ": ", err or ("[HTTP " .. res.status .. "] " .. res.body)) ngx.log(ngx.ERR, "Failed accounts service request /track/registry/" .. registry_action .. ": ", err or ("[HTTP " .. res.status .. "] " .. res.body))
end end
end end