Envoy: Accessing meta data such as method, uri (path + query) from Lua API

Created on 18 Mar 2020  路  4Comments  路  Source: envoyproxy/envoy

I am trying to figure out how can I access basic information such as request path and method from lua.
By looking through the docs, I could not see any option for this.

I was thinking of two possible options:

  1. Using metadata
  2. A prior filter that will feed this infomation to the headers

As for option no. 1, the question would be how can I can I set a dynamic entry, with variable such as those available for access log.

The following example _does not work_, it is just for concept demonstration

metadata:
  filter_metadata:
    envoy.filters.http.lua:
      path: "%REQ(:PATH)%"
      method: "%REQ(:METHOD)%"
      method2: "%METHOD%"

for option no. 2 _or any other idea_, I would love to get an example how to get it done.

docs:
https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/lua_filter.html

arelua question

All 4 comments

@tzuryby how about getting it directly from lua request handles?

https://www.envoyproxy.io/docs/envoy/latest/configuration/http/http_filters/lua_filter.html#config-http-filters-lua-header-wrapper

function envoy_on_request(request_handle)
  request_handle:logInfo(request_handle:headers():get(":path"))
end

awesome. had no idea headers is interface for meta data.
where can I find a list of all data available as in get(":data") ?

here I see :method, :path and :authority

Are there more?

These are HTTP/2 pseudo-headers: https://tools.ietf.org/html/rfc7540#section-8.1.2.3

many thanks!

Was this page helpful?
0 / 5 - 0 ratings