Lua Filter

EnRoute Technical Reference

Lua

Lua is a global plugin that enables attaching a lua script at the global level.

Lua Filter Configuration

When HTTP request traffic hits GatewayHost, the function (envoy_on_request()) is invoked on the request path and the function envoy_on_response() is invoked on the response path.

Lua Filter Config for KubernetesLua Filter Config for Standalone

---
apiVersion: enroute.saaras.io/v1        
kind: HttpFilter
metadata:
  name: global_lua_filter
  namespace: enroute-gw-k8s
spec:
  name: global_lua_filter
  type: http_filter_lua
  routeFilterConfig:
    config: |
  function envoy_on_request(request_handle)
      request_handle:logInfo("Hello World request")
  end

  function envoy_on_response(response_handle)
    response_handle:logInfo("Hello World response")
  end


# Variables for lua global filter
FILTER_NAME="global_lua_filter"
FILTER_TYPE="http_filter_lua"
FILTER_CONFIG='
  function envoy_on_request(request_handle)
      request_handle:logInfo("Hello World request")
  end

  function envoy_on_response(response_handle)
    response_handle:logInfo("Hello World response")
  end
'

curl -s -X POST localhost:1323/filter         \
        -d "Filter_name=${FILTER_NAME}"       \
        -d "Filter_type=${FILTER_TYPE}"       \
        -d "Filter_config"="${FILTER_CONFIG}"

Notes

Lua plugin is included with OSS Edition

Lua plugin is a global HttpFilter. It sets configuration on the Listener and is applicable to all GatewayHost when defined.