Skip to content

Commit

Permalink
fix v1 adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
eschultink committed Oct 24, 2024
1 parent 76922b5 commit 9e123d2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ public class APIGatewayV1ProxyEventRequestAdapter implements co.worklytics.psoxy

@Override
public String getPath() {
String resourcePath;
if (event.getRequestContext() != null) {
resourcePath = event.getRequestContext().getResourcePath();
} else {
resourcePath = ObjectUtils.firstNonNull(event.getResource(), event.getPath());
}
String resourcePath = event.getPath();

String route = event.getResource().replace("{proxy+}", "");

resourcePath = StringUtils.removeStart(resourcePath, "/" + event.getRequestContext().getStage() + route);

return StringUtils.prependIfMissing(resourcePath, "/");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,17 @@ public void parse_interesting() {

assertFalse(requestAdapter.isHttps().isPresent());
}

@SneakyThrows
@Test
public void parse_payload1_from_api_gateway_v2() {

APIGatewayProxyRequestEvent apiGatewayEvent = objectMapper.readerFor(APIGatewayProxyRequestEvent.class)
.readValue(TestUtils.getData("lambda-proxy-events/api-gateway-v2-payload-v1.json"));

APIGatewayV1ProxyEventRequestAdapter requestAdapter =
APIGatewayV1ProxyEventRequestAdapter.of(apiGatewayEvent);

assertEquals("/v2/report/meetings/NUXghb123TCj0bP6nPVe%252Fsg253D253D/participants", requestAdapter.getPath());
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "1.0",
"resource": "/psoxy-zoom/{proxy+}",
"path": "/live/ipsoxy-zoom/v2/report/meetings/NUXghb123TCj0bP6nPVe%252Fsg253D253D/participants",
"path": "/live/psoxy-zoom/v2/report/meetings/NUXghb123TCj0bP6nPVe%252Fsg253D253D/participants",
"httpMethod": "GET",
"headers": {
"Content-Length": "0",
Expand Down

0 comments on commit 9e123d2

Please sign in to comment.