mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(apigateway): project HTTP API v2 cookies (#2391)
* fix(apigateway): project HTTP API v2 cookies * test(apigateway): cover cookie and header coexistence
This commit is contained in:
1 parent
41953d8820
commit
48880aa79a
2 files changed
+79
-10
No files matched your search
+9
-3
@@ -401,7 +401,7 @@ public class ApiGatewayExecuteController {
|
||||
try {
|
||||
InvokeResult result = lambdaService.invoke(region, functionName, eventJson.getBytes(),
|
||||
InvocationType.RequestResponse);
|
||||
return buildProxyResponse(result);
|
||||
return buildProxyResponse(result, false);
|
||||
} catch (AwsException e) {
|
||||
if (e.getHttpStatus() == 404) {
|
||||
return Response.status(404)
|
||||
@@ -839,7 +839,7 @@ public class ApiGatewayExecuteController {
|
||||
}
|
||||
}
|
||||
|
||||
Response buildProxyResponse(InvokeResult result) {
|
||||
Response buildProxyResponse(InvokeResult result, boolean httpApiV2) {
|
||||
if (result.getPayload() == null || result.getPayload().length == 0) {
|
||||
return Response.status(result.getFunctionError() != null ? 502 : result.getStatusCode()).build();
|
||||
}
|
||||
@@ -860,6 +860,12 @@ public class ApiGatewayExecuteController {
|
||||
if (e.getValue().isArray()) e.getValue().forEach(v -> builder.header(e.getKey(), v.asText()));
|
||||
});
|
||||
}
|
||||
if (httpApiV2) {
|
||||
JsonNode cookies = node.get("cookies");
|
||||
if (cookies != null && cookies.isArray()) {
|
||||
cookies.forEach(cookie -> builder.header(HttpHeaders.SET_COOKIE, cookie.asText()));
|
||||
}
|
||||
}
|
||||
|
||||
JsonNode bodyNode = node.get("body");
|
||||
if (bodyNode != null && !bodyNode.isNull()) {
|
||||
@@ -1419,7 +1425,7 @@ public class ApiGatewayExecuteController {
|
||||
try {
|
||||
InvokeResult result = lambdaService.invoke(region, functionName,
|
||||
eventJson.getBytes(), InvocationType.RequestResponse);
|
||||
return buildProxyResponse(result);
|
||||
return buildProxyResponse(result, true);
|
||||
} catch (AwsException e) {
|
||||
if (e.getHttpStatus() == 404) {
|
||||
return Response.status(404)
|
||||
|
||||
Reference in new issue
Block a user