diff --git a/kong-plugin-aws-lambda-status-code-0.1.0-1.rockspec b/kong-plugin-aws-lambda-status-code-0.2.0-1.rockspec similarity index 94% rename from kong-plugin-aws-lambda-status-code-0.1.0-1.rockspec rename to kong-plugin-aws-lambda-status-code-0.2.0-1.rockspec index 6cc0256..ebe5102 100644 --- a/kong-plugin-aws-lambda-status-code-0.1.0-1.rockspec +++ b/kong-plugin-aws-lambda-status-code-0.2.0-1.rockspec @@ -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. @@ -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 = { diff --git a/kong/plugins/aws-lambda-status-code/handler.lua b/kong/plugins/aws-lambda-status-code/handler.lua index c26203d..27615bb 100644 --- a/kong/plugins/aws-lambda-status-code/handler.lua +++ b/kong/plugins/aws-lambda-status-code/handler.lua @@ -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 @@ -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)