Skip to content

Commit f655794

Browse files
committed
chore(plugins/aws-lambda): adopt lua-resty-aws v1.6.0 to simplify code
See Kong/lua-resty-aws#119
1 parent 54f8306 commit f655794

File tree

4 files changed

+22
-391
lines changed

4 files changed

+22
-391
lines changed

kong/plugins/aws-lambda/aws_stream.lua

-195
This file was deleted.

kong/plugins/aws-lambda/execute.lua

-166
This file was deleted.

kong/plugins/aws-lambda/handler.lua

+6-9
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ local VIA_HEADER = constants.HEADERS.VIA
1616
local VIA_HEADER_VALUE = meta._NAME .. "/" .. meta._VERSION
1717

1818
local request_util = require "kong.plugins.aws-lambda.request-util"
19-
local AWS_Stream = require("kong.plugins.aws-lambda.aws_stream")
20-
local invokeWithResponseStream = require "kong.plugins.aws-lambda.execute"
19+
local AWS_Stream = require("resty.aws.stream")
2120
local build_request_payload = request_util.build_request_payload
2221
local extract_proxy_response = request_util.extract_proxy_response
2322
local remove_array_mt_for_empty_table = request_util.remove_array_mt_for_empty_table
@@ -170,7 +169,7 @@ local function invoke_streaming(conf, lambda_service)
170169
-- TRACING: set KONG_WAITING_TIME start
171170
local kong_wait_time_start = get_now()
172171

173-
local res, err = invokeWithResponseStream(lambda_service, {
172+
local res, err = lambda_service:invokeWithResponseStream({
174173
FunctionName = conf.function_name,
175174
InvocationType = conf.invocation_type,
176175
LogType = conf.log_type,
@@ -263,12 +262,10 @@ local function invoke_streaming(conf, lambda_service)
263262
end
264263

265264
-- print(require("pl.pretty").write(msg))
266-
for _, header in ipairs(msg.headers) do
267-
if header.key == ":event-type" and header.value == "PayloadChunk" then
268-
-- print(msg.body)
269-
ngx.print(msg.body)
270-
ngx.flush(true)
271-
end
265+
if msg.headers[":event-type"] == "PayloadChunk" then
266+
-- print(msg.body)
267+
ngx.print(msg.body)
268+
ngx.flush(true)
272269
end
273270
end
274271
end

0 commit comments

Comments
 (0)