Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package = "kong-plugin-aws-lambda-status-code" -- TODO: rename, must match the info in the filename of this rockspec!
-- as a convention; stick to the prefix: `kong-plugin-`
version = "0.1.0-1" -- TODO: renumber, must match the info in the filename of this rockspec!
version = "0.2.0-1" -- TODO: renumber, must match the info in the filename of this rockspec!
-- The version '0.1.0' is the source code version, the trailing '1' is the version of this rockspec.
-- whenever the source version changes, the rockspec should be reset to 1. The rockspec version is only
-- updated (incremented) when this file changes, but the source remains the same.
Expand All @@ -12,7 +12,7 @@ supported_platforms = {"linux", "macosx"}
source = {
-- these are initially not required to make it work
url = "git://github.com/iyp-uk/aws-lambda-status-code",
tag = "0.1.0"
tag = "0.2.0"
}

description = {
Expand Down
11 changes: 10 additions & 1 deletion kong/plugins/aws-lambda-status-code/handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ function AWSLambdaStatusCodeHandler:access(conf)
params, err = cjson.decode(body)
local statusCode = params.statusCode
local resource = params.resource
local lambdaHeaders = params.headers
if statusCode ~= nil then
ngx.header['X-lambda-original-status'] = res.status
ngx.status = statusCode
Expand All @@ -163,14 +164,22 @@ function AWSLambdaStatusCodeHandler:access(conf)
headers['Content-Length'] = nil
body = cjson.encode(resource)
end

--Set headers returned in JSON body
if type(lambdaHeaders) == type({}) then

for k,v in pairs(lambdaHeaders) do
headers[k] = v
end
end
end
end

-- Send response to client
for k, v in pairs(headers) do
ngx.header[k] = v
end

-- Send response to client
ngx.say(body)

return ngx.exit(res.status)
Expand Down