-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05-function-call.yml
42 lines (42 loc) · 1.4 KB
/
05-function-call.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: function-call
namespace: sock-shop
spec:
workloadSelector:
labels:
name: front-end
configPatches:
- applyTo: HTTP_FILTER
match:
context: SIDECAR_INBOUND
listener:
portNumber: 8079
filterChain:
filter:
name: "envoy.filters.network.http_connection_manager"
subFilter:
name: "envoy.filters.http.router"
patch:
operation: INSERT_BEFORE
value:
name: envoy.filters.http.lua
typed_config:
"@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua"
inlineCode: |
JSON = (loadfile "/var/lib/lua/JSON.lua")()
function element_counts(rh)
rh:logCritical("invoke")
end
function envoy_on_request(request_handle)
request_handle:logCritical("Hello World 19")
local body_obj = request_handle:body()
if body_obj ~= nil then
local body_bytes = body_obj:getBytes(0, body_obj:length())
request_handle:logCritical("Body:"..body_bytes)
local raw_json_text = tostring(body_bytes)
local body_json = JSON:decode(raw_json_text)
element_counts(request_handle)
end
end