Lua Route Filter

RouteFilter Lua

Invoke Lua script per-route by creating a RouteFilter and attaching it to a Route in GatewayHost or ServiceRoute

apiVersion: enroute.saaras.io/v1
kind: RouteFilter
metadata:
  labels:
    component: lua
    configscope: vhconfig
  name: luafilter
  namespace: httpbin
  resourceVersion: "1224971"
  uid: dce13863-418f-47e5-a354-434a9a739e08
spec:
  name: luafilter
  routeFilterConfig:
    config: |
      function envoy_on_request(request_handle)
       -- nothing to do on request path
      end

      function envoy_on_response(response_handle)
         -- if response is a 500, update it to 404 with a friendly message
         if response_handle:headers():get(":status") == "500" then
           response_handle:body():setBytes("<html><b>This should not have happened!<b></html>")
           response_handle:headers():replace(":status", 404)
         end
      end
  type: route_filter_lua