Envoy
Envoy Proxy Configuration
The following Lua Request and Response filters can be used to meter arbitrary API traffic passing through an Envoy Proxy.
request.lua
function envoy_on_request(request_handle)
local api_client = request_handle:headers():get("x-revenium-product-key")
if (api_client ~= nil) then
if request_handle:connection():ssl() == nil then
request_handle:streamInfo():dynamicMetadata():set("revenium", "scheme", "http")
else
request_handle:streamInfo():dynamicMetadata():set("revenium", "scheme", "https")
end
local method = request_handle:headers():get(":method")
local path = request_handle:headers():get(":path")
request_handle:streamInfo():dynamicMetadata():set("revenium", "address", address)
request_handle:streamInfo():dynamicMetadata():set("revenium", "method", method)
request_handle:streamInfo():dynamicMetadata():set("revenium", "path", path)
request_handle:streamInfo():dynamicMetadata():set("revenium", "api_client", api_client)
end
endresponse.lua
Last updated
Was this helpful?