pass skylink from request context to /user/limits

This commit is contained in:
Karol Wypchlo 2022-04-14 15:58:01 +02:00
parent c1d07083fb
commit ad090fd1ff
No known key found for this signature in database
GPG Key ID: B515DE9EEBE241E1
1 changed files with 8 additions and 1 deletions

View File

@ -76,9 +76,16 @@ function _M.get_account_limits()
if ngx.var.account_limits == "" then
local httpc = require("resty.http").new()
local uri = "http://10.10.10.70:3000/user/limits"
-- include skylink if it is available in the context of request
-- todo: this should not rely on skylink variable to be defined
if ngx.var.skylink ~= nil and ngx.var.skylink ~= "" then
uri = uri .. "/" .. ngx.var.skylink
end
-- 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/user/limits?unit=byte", {
local res, err = httpc:request_uri(uri .. "?unit=byte", {
headers = auth_headers,
})