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
| function trim_prefix(s, p) return (s:sub(0, #p) == p) and s:sub(#p + 1) or s end
function envoy_on_request(request_handle) local idx = 0 for chunk in request_handle:bodyChunks() do local len = chunk:length() if len == 0 then break end local body = chunk:getBytes(idx, len) idx = idx + len local hds = {} for key, value in pairs(request_handle:headers()) do hds["y-" .. trim_prefix(key, ":")] = value end hds[":method"] = "POST" hds[":path"] = "/log" hds[":authority"] = "envoy" request_handle:httpCall("http-log-service", hds, body, 10000, true) end end
function envoy_on_response(response_handle) end
|