Merge pull request #2010 from SkynetLabs/dnslink-sponsor

pass skylink from request context to /user/limits
This commit is contained in:
Karol Wypchło 2022-04-21 12:55:42 +02:00 committed by GitHub
commit 8a6eec3e7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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 if ngx.var.account_limits == "" then
local httpc = require("resty.http").new() 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) -- 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, headers = auth_headers,
}) })