我有lua代码来调用微服务。现在我用
local requestId = ngx.req.get_headers()['X-Request-Id']
local host = ngx.req.get_headers()['Host']
local xForwardedProto = ngx.req.get_headers()['X-Forwarded-Proto']
local xForwardedPort = ngx.req.get_headers()['X-Forwarded-Port']
local xForwardedFor = ngx.req.get_headers()['X-Forwarded-For']
local xRealIP = ngx.req.get_headers()['X-Real-IP']
#####and some logic after that call####
local res = httpc:request_uri(targetURL, {
method = "GET",
ssl_verify = false,
headers = {
["Authorization"] = "Bearer " .. ngx.var.unique_token,
["X-Request-Id"] = requestId,
["Cache-Control"] = ngx.req.get_headers()['Cache-Control']
}
})
如何在不知道标题名称的情况下以编程方式传递所有标题?