1

I know that 2 Lua functions are called in a filter when a call is made :

function envoy_on_request(request_handle)
end

function envoy_on_response(response_handle)
end

How can I retrieve the Request URI Path/query params from the request_handle?

EDIT: I found a couple of headers called ":path" and "x-original-url" but which is the source of truth?

Jerald Baker
  • 1,121
  • 1
  • 12
  • 48

1 Answers1

1

You have access to all the headers in a request/response using handle:headers().

function envoy_on_request(request_handle)
  -- Log information about the request
  request_handle:logInfo("URL: "..request_handle:headers():get(":x-original-url"))
  request_handle:logInfo("Path: "..request_handle:headers():get(":path"))
end

function envoy_on_response(response_handle)
  -- Log response status code
  response_handle:logInfo("Status: "..response_handle:headers():get(":status"))
end
Amila Senadheera
  • 12,229
  • 15
  • 27
  • 43