scopes = new ArrayList<>();
- scopes.add("first");
- scopes.add("second");
- req.getRequestContext().getAuthorizer().getJwtAuthorizer().setScopes(scopes);
-
- try {
- String reqString = LambdaContainerHandler.getObjectMapper().writeValueAsString(req);
- assertTrue(reqString.contains("\"scopes\":[\"first\",\"second\"]"));
- assertTrue(reqString.contains("\"authorizer\":{\"jwt\":{"));
- assertTrue(reqString.contains("\"isBase64Encoded\":false"));
- } catch (JsonProcessingException e) {
- e.printStackTrace();
- fail("Exception while serializing request" + e.getMessage());
- }
- }
-}
diff --git a/aws-serverless-java-container-jersey/src/main/java/com/amazonaws/serverless/proxy/jersey/JerseyLambdaContainerHandler.java b/aws-serverless-java-container-jersey/src/main/java/com/amazonaws/serverless/proxy/jersey/JerseyLambdaContainerHandler.java
index e290e284b..3ea99e329 100644
--- a/aws-serverless-java-container-jersey/src/main/java/com/amazonaws/serverless/proxy/jersey/JerseyLambdaContainerHandler.java
+++ b/aws-serverless-java-container-jersey/src/main/java/com/amazonaws/serverless/proxy/jersey/JerseyLambdaContainerHandler.java
@@ -19,12 +19,13 @@
import com.amazonaws.serverless.proxy.jersey.suppliers.AwsProxyServletContextSupplier;
import com.amazonaws.serverless.proxy.jersey.suppliers.AwsProxyServletRequestSupplier;
import com.amazonaws.serverless.proxy.jersey.suppliers.AwsProxyServletResponseSupplier;
-import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
-import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
-import com.amazonaws.serverless.proxy.model.HttpApiV2ProxyRequest;
import com.amazonaws.services.lambda.runtime.Context;
+import com.amazonaws.services.lambda.runtime.events.ApplicationLoadBalancerRequestEvent;
+import com.amazonaws.services.lambda.runtime.events.AwsProxyResponseEvent;
+import com.amazonaws.services.lambda.runtime.events.apigateway.APIGatewayProxyRequestEvent;
+import com.amazonaws.services.lambda.runtime.events.apigateway.APIGatewayV2HTTPEvent;
import org.glassfish.jersey.internal.inject.AbstractBinder;
import org.glassfish.jersey.internal.inject.InjectionManager;
import org.glassfish.jersey.process.internal.RequestScoped;
@@ -50,11 +51,11 @@
*
*
* {@code
- * public class LambdaHandler implements RequestHandler {
+ * public class LambdaHandler implements RequestHandler {
* private ResourceConfig jerseyApplication = new ResourceConfig().packages("your.app.package");
* private JerseyLambdaContainerHandler container = JerseyLambdaContainerHandler.getAwsProxyHandler(jerseyApplication);
*
- * public AwsProxyResponse handleRequest(AwsProxyRequest awsProxyRequest, Context context) {
+ * public AwsProxyResponse handleRequest(APIGatewayProxyRequestEvent awsProxyRequest, Context context) {
* return container.proxy(awsProxyRequest, context);
* }
* }
@@ -81,17 +82,17 @@ public class JerseyLambdaContainerHandler extends Aws
/**
* Returns an initialized JerseyLambdaContainerHandler
that includes RequestReader
and
- * ResponseWriter
objects for the AwsProxyRequest
and AwsProxyResponse
+ * ResponseWriter
objects for the APIGatewayProxyRequestEvent
and AwsProxyResponse
* objects.
*
* @param jaxRsApplication A configured Jax-Rs application object. For Jersey apps this can be the default
* ResourceConfig
object
* @return A JerseyLambdaContainerHandler
object
*/
- public static JerseyLambdaContainerHandler getAwsProxyHandler(Application jaxRsApplication) {
- JerseyLambdaContainerHandler newHandler = new JerseyLambdaContainerHandler<>(
- AwsProxyRequest.class,
- AwsProxyResponse.class,
+ public static JerseyLambdaContainerHandler getAwsProxyHandler(Application jaxRsApplication) {
+ JerseyLambdaContainerHandler newHandler = new JerseyLambdaContainerHandler<>(
+ APIGatewayProxyRequestEvent.class,
+ AwsProxyResponseEvent.class,
new AwsProxyHttpServletRequestReader(),
new AwsProxyHttpServletResponseWriter(),
new AwsProxySecurityContextWriter(),
@@ -110,10 +111,10 @@ public static JerseyLambdaContainerHandler ge
* ResourceConfig
object
* @return A JerseyLambdaContainerHandler
object
*/
- public static JerseyLambdaContainerHandler getHttpApiV2ProxyHandler(Application jaxRsApplication) {
- JerseyLambdaContainerHandler newHandler = new JerseyLambdaContainerHandler<>(
- HttpApiV2ProxyRequest.class,
- AwsProxyResponse.class,
+ public static JerseyLambdaContainerHandler getHttpApiV2ProxyHandler(Application jaxRsApplication) {
+ JerseyLambdaContainerHandler newHandler = new JerseyLambdaContainerHandler<>(
+ APIGatewayV2HTTPEvent.class,
+ AwsProxyResponseEvent.class,
new AwsHttpApiV2HttpServletRequestReader(),
new AwsProxyHttpServletResponseWriter(true),
new AwsHttpApiV2SecurityContextWriter(),
@@ -123,6 +124,19 @@ public static JerseyLambdaContainerHandler getAlbProxyHandler(Application jaxRsApplication) {
+ JerseyLambdaContainerHandler newHandler = new JerseyLambdaContainerHandler<>(
+ ApplicationLoadBalancerRequestEvent.class,
+ AwsProxyResponseEvent.class,
+ new AwsAlbHttpServletRequestReader(),
+ new AwsProxyHttpServletResponseWriter(true),
+ new AwsAlbSecurityContextWriter(),
+ new AwsAlbExceptionHandler(),
+ jaxRsApplication);
+ newHandler.initialize();
+ return newHandler;
+ }
+
//-------------------------------------------------------------
// Constructors
diff --git a/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/EchoJerseyResource.java b/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/EchoJerseyResource.java
index d05c6814f..c3ab2dac8 100644
--- a/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/EchoJerseyResource.java
+++ b/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/EchoJerseyResource.java
@@ -14,10 +14,10 @@
import com.amazonaws.serverless.proxy.RequestReader;
import com.amazonaws.serverless.proxy.jersey.providers.ServletRequestFilter;
-import com.amazonaws.serverless.proxy.model.AwsProxyRequestContext;
import com.amazonaws.serverless.proxy.jersey.model.MapResponseModel;
import com.amazonaws.serverless.proxy.jersey.model.SingleValueModel;
+import com.amazonaws.services.lambda.runtime.events.apigateway.APIGatewayProxyRequestEvent;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam;
@@ -157,9 +157,9 @@ public SingleValueModel echoRequestScheme(@Context UriInfo context) {
@Produces(MediaType.APPLICATION_JSON)
public SingleValueModel echoAuthorizerPrincipal(@Context ContainerRequestContext context) {
SingleValueModel valueModel = new SingleValueModel();
- AwsProxyRequestContext awsProxyRequestContext =
- (AwsProxyRequestContext) context.getProperty(RequestReader.API_GATEWAY_CONTEXT_PROPERTY);
- valueModel.setValue(awsProxyRequestContext.getAuthorizer().getPrincipalId());
+ APIGatewayProxyRequestEvent.ProxyRequestContext awsProxyRequestContext =
+ (APIGatewayProxyRequestEvent.ProxyRequestContext) context.getProperty(RequestReader.API_GATEWAY_CONTEXT_PROPERTY);
+ valueModel.setValue(awsProxyRequestContext.getAuthorizer().get("principalId").toString());
return valueModel;
}
@@ -168,9 +168,9 @@ public SingleValueModel echoAuthorizerPrincipal(@Context ContainerRequestContext
@Produces(MediaType.APPLICATION_JSON)
public SingleValueModel echoAuthorizerContext(@Context ContainerRequestContext context, @QueryParam("key") String key) {
SingleValueModel valueModel = new SingleValueModel();
- AwsProxyRequestContext awsProxyRequestContext =
- (AwsProxyRequestContext) context.getProperty(RequestReader.API_GATEWAY_CONTEXT_PROPERTY);
- valueModel.setValue(awsProxyRequestContext.getAuthorizer().getContextValue(key));
+ APIGatewayProxyRequestEvent.ProxyRequestContext awsProxyRequestContext =
+ (APIGatewayProxyRequestEvent.ProxyRequestContext) context.getProperty(RequestReader.API_GATEWAY_CONTEXT_PROPERTY);
+ valueModel.setValue(awsProxyRequestContext.getAuthorizer().get(key).toString());
return valueModel;
}
diff --git a/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/JerseyAwsProxyTest.java b/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/JerseyAwsProxyTest.java
index b845a0b69..4b432350e 100644
--- a/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/JerseyAwsProxyTest.java
+++ b/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/JerseyAwsProxyTest.java
@@ -20,10 +20,11 @@
import com.amazonaws.serverless.proxy.jersey.model.MapResponseModel;
import com.amazonaws.serverless.proxy.jersey.model.SingleValueModel;
import com.amazonaws.serverless.proxy.jersey.providers.ServletRequestFilter;
-import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
-import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
-import com.amazonaws.serverless.proxy.model.HttpApiV2ProxyRequest;
import com.amazonaws.services.lambda.runtime.Context;
+import com.amazonaws.services.lambda.runtime.events.ApplicationLoadBalancerRequestEvent;
+import com.amazonaws.services.lambda.runtime.events.AwsProxyResponseEvent;
+import com.amazonaws.services.lambda.runtime.events.apigateway.APIGatewayProxyRequestEvent;
+import com.amazonaws.services.lambda.runtime.events.apigateway.APIGatewayV2HTTPEvent;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.codec.binary.Base64;
@@ -41,6 +42,7 @@
import java.util.Collection;
import java.util.UUID;
+import static com.amazonaws.serverless.proxy.internal.servlet.AwsHttpServletRequest.getFirst;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -80,10 +82,18 @@ public class JerseyAwsProxyTest {
.register(MultiPartFeature.class)
.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY_SERVER, LoggingFeature.Verbosity.PAYLOAD_ANY);
- private static JerseyLambdaContainerHandler handler;
- private static JerseyLambdaContainerHandler httpApiHandler;
+ private static ResourceConfig albApp = new ResourceConfig().packages("com.amazonaws.serverless.proxy.jersey")
+ .register(LoggingFeature.class)
+ .register(ServletRequestFilter.class)
+ .register(MultiPartFeature.class)
+ .register(new ResourceBinder())
+ .property(LoggingFeature.LOGGING_FEATURE_VERBOSITY_SERVER, LoggingFeature.Verbosity.PAYLOAD_ANY);
- private static JerseyLambdaContainerHandler handlerWithoutRegisteredDependencies
+ private static JerseyLambdaContainerHandler handler;
+ private static JerseyLambdaContainerHandler httpApiHandler;
+ private static JerseyLambdaContainerHandler albHandler;
+
+ private static JerseyLambdaContainerHandler handlerWithoutRegisteredDependencies
= JerseyLambdaContainerHandler.getAwsProxyHandler(appWithoutRegisteredDependencies);
private static Context lambdaContext = new MockLambdaContext();
@@ -103,7 +113,7 @@ private AwsProxyRequestBuilder getRequestBuilder(String path, String method) {
return new AwsProxyRequestBuilder(path, method);
}
- private AwsProxyResponse executeRequest(AwsProxyRequestBuilder requestBuilder, Context lambdaContext) {
+ private AwsProxyResponseEvent executeRequest(AwsProxyRequestBuilder requestBuilder, Context lambdaContext) {
switch (type) {
case "API_GW":
if (handler == null) {
@@ -111,10 +121,10 @@ private AwsProxyResponse executeRequest(AwsProxyRequestBuilder requestBuilder, C
}
return handler.proxy(requestBuilder.build(), lambdaContext);
case "ALB":
- if (handler == null) {
- handler = JerseyLambdaContainerHandler.getAwsProxyHandler(app);
+ if (albHandler == null) {
+ albHandler = JerseyLambdaContainerHandler.getAlbProxyHandler(albApp);
}
- return handler.proxy(requestBuilder.alb().build(), lambdaContext);
+ return albHandler.proxy(requestBuilder.toAlbRequest(), lambdaContext);
case "HTTP_API":
if (httpApiHandler == null) {
httpApiHandler = JerseyLambdaContainerHandler.getHttpApiV2ProxyHandler(httpApiApp);
@@ -145,9 +155,9 @@ void headers_getHeaders_echo(String reqType) {
.json()
.header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE);
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(200, output.getStatusCode());
- assertEquals("application/json", output.getMultiValueHeaders().getFirst("Content-Type"));
+ assertEquals("application/json", getFirst(output.getMultiValueHeaders(), "Content-Type"));
validateMapResponseModel(output);
}
@@ -160,9 +170,9 @@ void headers_servletRequest_echo(String reqType) {
.json()
.header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE);
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(200, output.getStatusCode());
- assertEquals("application/json", output.getMultiValueHeaders().getFirst("Content-Type"));
+ assertEquals("application/json", getFirst(output.getMultiValueHeaders(), "Content-Type"));
validateMapResponseModel(output);
}
@@ -172,13 +182,13 @@ void headers_servletRequest_echo(String reqType) {
void headers_servletRequest_failedDependencyInjection_expectInternalServerError(String reqType) {
initJerseyAwsProxyTest(reqType);
assumeTrue("API_GW".equals(type));
- AwsProxyRequest request = getRequestBuilder("/echo/servlet-headers", "GET")
+ APIGatewayProxyRequestEvent request = getRequestBuilder("/echo/servlet-headers", "GET")
.json()
.header(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE)
.build();
- AwsProxyResponse output = handlerWithoutRegisteredDependencies.proxy(request, lambdaContext);
- assertEquals("application/json", output.getMultiValueHeaders().getFirst("Content-Type"));
+ AwsProxyResponseEvent output = handlerWithoutRegisteredDependencies.proxy(request, lambdaContext);
+ assertEquals("application/json", getFirst(output.getMultiValueHeaders(), "Content-Type"));
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), output.getStatusCode());
}
@@ -189,7 +199,7 @@ void context_servletResponse_setCustomHeader(String reqType) {
AwsProxyRequestBuilder request = getRequestBuilder("/echo/servlet-response", "GET")
.json();
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(200, output.getStatusCode());
assertTrue(output.getMultiValueHeaders().containsKey(EchoJerseyResource.SERVLET_RESP_HEADER_KEY));
}
@@ -199,9 +209,9 @@ void context_servletResponse_setCustomHeader(String reqType) {
void context_serverInfo_correctContext(String reqType) {
initJerseyAwsProxyTest(reqType);
AwsProxyRequestBuilder request = getRequestBuilder("/echo/servlet-context", "GET");
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(200, output.getStatusCode());
- assertEquals("application/json", output.getMultiValueHeaders().getFirst("Content-Type"));
+ assertEquals("application/json", getFirst(output.getMultiValueHeaders(), "Content-Type"));
validateSingleValueModel(output, AwsServletContext.SERVER_INFO);
}
@@ -213,9 +223,9 @@ void requestScheme_valid_expectHttps(String reqType) {
AwsProxyRequestBuilder request = getRequestBuilder("/echo/scheme", "GET")
.json();
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(200, output.getStatusCode());
- assertEquals("application/json", output.getMultiValueHeaders().getFirst("Content-Type"));
+ assertEquals("application/json", getFirst(output.getMultiValueHeaders(), "Content-Type"));
validateSingleValueModel(output, "https");
}
@@ -227,9 +237,9 @@ void requestFilter_injectsServletRequest_expectCustomAttribute(String reqType) {
AwsProxyRequestBuilder request = getRequestBuilder("/echo/filter-attribute", "GET")
.json();
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(200, output.getStatusCode());
- assertEquals("application/json", output.getMultiValueHeaders().getFirst("Content-Type"));
+ assertEquals("application/json", getFirst(output.getMultiValueHeaders(), "Content-Type"));
validateSingleValueModel(output, ServletRequestFilter.FILTER_ATTRIBUTE_VALUE);
}
@@ -243,9 +253,9 @@ void authorizer_securityContext_customPrincipalSuccess(String reqType) {
.json()
.authorizerPrincipal(AUTHORIZER_PRINCIPAL_ID);
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(200, output.getStatusCode());
- assertEquals("application/json", output.getMultiValueHeaders().getFirst("Content-Type"));
+ assertEquals("application/json", getFirst(output.getMultiValueHeaders(), "Content-Type"));
validateSingleValueModel(output, AUTHORIZER_PRINCIPAL_ID);
}
@@ -260,9 +270,9 @@ void authorizer_securityContext_customAuthorizerContextSuccess(String reqType) {
.authorizerContextValue(CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE)
.queryString("key", CUSTOM_HEADER_KEY);
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(200, output.getStatusCode());
- assertEquals("application/json", output.getMultiValueHeaders().getFirst("Content-Type"));
+ assertEquals("application/json", getFirst(output.getMultiValueHeaders(), "Content-Type"));
validateSingleValueModel(output, CUSTOM_HEADER_VALUE);
}
@@ -273,7 +283,7 @@ void errors_unknownRoute_expect404(String reqType) {
initJerseyAwsProxyTest(reqType);
AwsProxyRequestBuilder request = getRequestBuilder("/echo/test33", "GET");
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(404, output.getStatusCode());
}
@@ -285,7 +295,7 @@ void error_contentType_invalidContentType(String reqType) {
.header("Content-Type", "application/octet-stream")
.body("asdasdasd");
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(415, output.getStatusCode());
}
@@ -297,7 +307,7 @@ void error_statusCode_methodNotAllowed(String reqType) {
.json()
.queryString("status", "201");
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(405, output.getStatusCode());
}
@@ -311,7 +321,7 @@ void responseBody_responseWriter_validBody(String reqType) throws JsonProcessing
.json()
.body(objectMapper.writeValueAsString(singleValueModel));
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(200, output.getStatusCode());
assertNotNull(output.getBody());
@@ -326,7 +336,7 @@ void statusCode_responseStatusCode_customStatusCode(String reqType) {
.json()
.queryString("status", "201");
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(201, output.getStatusCode());
}
@@ -336,7 +346,7 @@ void base64_binaryResponse_base64Encoding(String reqType) {
initJerseyAwsProxyTest(reqType);
AwsProxyRequestBuilder request = getRequestBuilder("/echo/binary", "GET");
- AwsProxyResponse response = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent response = executeRequest(request, lambdaContext);
assertNotNull(response.getBody());
assertTrue(Base64.isBase64(response.getBody()));
}
@@ -347,7 +357,7 @@ void exception_mapException_mapToNotImplemented(String reqType) {
initJerseyAwsProxyTest(reqType);
AwsProxyRequestBuilder request = getRequestBuilder("/echo/exception", "GET");
- AwsProxyResponse response = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent response = executeRequest(request, lambdaContext);
assertNotNull(response.getBody());
assertEquals(EchoJerseyResource.EXCEPTION_MESSAGE, response.getBody());
assertEquals(Response.Status.NOT_IMPLEMENTED.getStatusCode(), response.getStatusCode());
@@ -361,7 +371,7 @@ void stripBasePath_route_shouldRouteCorrectly(String reqType) {
.json()
.queryString("status", "201");
getHandler().stripBasePath("/custompath");
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(201, output.getStatusCode());
getHandler().stripBasePath("");
}
@@ -377,7 +387,7 @@ void stripBasePath_route_shouldReturn404WithStageAsContext(String reqType) {
.queryString("status", "201");
getHandler().stripBasePath("/custompath");
LambdaContainerHandler.getContainerConfig().setUseStageAsServletContext(true);
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(404, output.getStatusCode());
getHandler().stripBasePath("");
LambdaContainerHandler.getContainerConfig().setUseStageAsServletContext(false);
@@ -391,7 +401,7 @@ void stripBasePath_route_shouldReturn404(String reqType) {
.json()
.queryString("status", "201");
getHandler().stripBasePath("/custom");
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(404, output.getStatusCode());
getHandler().stripBasePath("");
}
@@ -404,7 +414,7 @@ void securityContext_injectPrincipal_expectPrincipalName(String reqType) {
AwsProxyRequestBuilder request = getRequestBuilder("/echo/security-context", "GET")
.authorizerPrincipal(USER_PRINCIPAL);
- AwsProxyResponse resp = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent resp = executeRequest(request, lambdaContext);
assertEquals(200, resp.getStatusCode());
validateSingleValueModel(resp, USER_PRINCIPAL);
}
@@ -416,7 +426,7 @@ void emptyStream_putNullBody_expectPutToSucceed(String reqType) {
AwsProxyRequestBuilder request = getRequestBuilder("/echo/empty-stream/" + CUSTOM_HEADER_KEY + "/test/2", "PUT")
.nullBody()
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
- AwsProxyResponse resp = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent resp = executeRequest(request, lambdaContext);
assertEquals(200, resp.getStatusCode());
validateSingleValueModel(resp, CUSTOM_HEADER_KEY);
}
@@ -431,7 +441,7 @@ void refererHeader_headerParam_expectCorrectInjection(String reqType) {
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.header("Referer", refererValue);
- AwsProxyResponse resp = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent resp = executeRequest(request, lambdaContext);
assertEquals(200, resp.getStatusCode());
validateSingleValueModel(resp, refererValue);
}
@@ -445,17 +455,17 @@ void textPlainContent_plain_responseHonorsContentType(String reqType) {
.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON)
.header(HttpHeaders.ACCEPT, MediaType.TEXT_PLAIN);
- AwsProxyResponse resp = executeRequest(req, lambdaContext);
+ AwsProxyResponseEvent resp = executeRequest(req, lambdaContext);
assertEquals(200, resp.getStatusCode());
assertTrue(resp.getMultiValueHeaders().containsKey(HttpHeaders.CONTENT_TYPE));
assertEquals(MediaType.TEXT_PLAIN, resp.getMultiValueHeaders().get(HttpHeaders.CONTENT_TYPE).get(0));
}
- private void validateMapResponseModel(AwsProxyResponse output) {
+ private void validateMapResponseModel(AwsProxyResponseEvent output) {
validateMapResponseModel(output, CUSTOM_HEADER_KEY, CUSTOM_HEADER_VALUE);
}
- private void validateMapResponseModel(AwsProxyResponse output, String key, String value) {
+ private void validateMapResponseModel(AwsProxyResponseEvent output, String key, String value) {
try {
MapResponseModel response = objectMapper.readValue(output.getBody(), MapResponseModel.class);
assertNotNull(response.getValues().get(key));
@@ -466,7 +476,7 @@ private void validateMapResponseModel(AwsProxyResponse output, String key, Strin
}
}
- private void validateSingleValueModel(AwsProxyResponse output, String value) {
+ private void validateSingleValueModel(AwsProxyResponseEvent output, String value) {
try {
SingleValueModel response = objectMapper.readValue(output.getBody(), SingleValueModel.class);
assertNotNull(response.getValue());
diff --git a/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/JerseyInjectionTest.java b/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/JerseyInjectionTest.java
index e253f34a3..bf10d766c 100644
--- a/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/JerseyInjectionTest.java
+++ b/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/JerseyInjectionTest.java
@@ -15,14 +15,14 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import com.amazonaws.services.lambda.runtime.events.AwsProxyResponseEvent;
+import com.amazonaws.services.lambda.runtime.events.apigateway.APIGatewayProxyRequestEvent;
import jakarta.inject.Singleton;
import org.glassfish.jersey.internal.inject.AbstractBinder;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.jupiter.api.Test;
-import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
-import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
/**
* Test that one can access the Jersey injection manager
@@ -42,7 +42,7 @@ protected void configure() {
private static ResourceConfig app = new ResourceConfig().register(MultiPartFeature.class)
.register(new ResourceBinder());
- private static JerseyLambdaContainerHandler handler = JerseyLambdaContainerHandler.getAwsProxyHandler(
+ private static JerseyLambdaContainerHandler handler = JerseyLambdaContainerHandler.getAwsProxyHandler(
app);
@Test
diff --git a/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/JerseyParamEncodingTest.java b/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/JerseyParamEncodingTest.java
index 9dc1ab32a..28f237ddf 100644
--- a/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/JerseyParamEncodingTest.java
+++ b/aws-serverless-java-container-jersey/src/test/java/com/amazonaws/serverless/proxy/jersey/JerseyParamEncodingTest.java
@@ -6,12 +6,15 @@
import com.amazonaws.serverless.proxy.internal.testutils.MockLambdaContext;
import com.amazonaws.serverless.proxy.jersey.model.MapResponseModel;
import com.amazonaws.serverless.proxy.jersey.model.SingleValueModel;
-import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
-import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
-import com.amazonaws.serverless.proxy.model.HttpApiV2ProxyRequest;
+import com.amazonaws.serverless.proxy.jersey.providers.ServletRequestFilter;
import com.amazonaws.services.lambda.runtime.Context;
+import com.amazonaws.services.lambda.runtime.events.ApplicationLoadBalancerRequestEvent;
+import com.amazonaws.services.lambda.runtime.events.AwsProxyResponseEvent;
+import com.amazonaws.services.lambda.runtime.events.apigateway.APIGatewayProxyRequestEvent;
+import com.amazonaws.services.lambda.runtime.events.apigateway.APIGatewayV2HTTPEvent;
import com.fasterxml.jackson.databind.ObjectMapper;
+import org.glassfish.jersey.logging.LoggingFeature;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.junit.jupiter.api.Disabled;
@@ -26,6 +29,7 @@
import java.util.Arrays;
import java.util.Collection;
+import static com.amazonaws.serverless.proxy.internal.servlet.AwsHttpServletRequest.getFirst;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;
@@ -66,14 +70,22 @@ public class JerseyParamEncodingTest {
.register(new ResourceBinder())
.property("jersey.config.server.tracing.type", "ALL")
.property("jersey.config.server.tracing.threshold", "VERBOSE");
- private static JerseyLambdaContainerHandler handler;
+ private static JerseyLambdaContainerHandler handler;
private static ResourceConfig httpApiApp = new ResourceConfig().packages("com.amazonaws.serverless.proxy.jersey")
.register(MultiPartFeature.class)
.register(new ResourceBinder())
.property("jersey.config.server.tracing.type", "ALL")
.property("jersey.config.server.tracing.threshold", "VERBOSE");
- private static JerseyLambdaContainerHandler httpApiHandler;
+ private static JerseyLambdaContainerHandler httpApiHandler;
+
+ private static ResourceConfig albApp = new ResourceConfig().packages("com.amazonaws.serverless.proxy.jersey")
+ .register(LoggingFeature.class)
+ .register(ServletRequestFilter.class)
+ .register(MultiPartFeature.class)
+ .register(new ResourceBinder())
+ .property(LoggingFeature.LOGGING_FEATURE_VERBOSITY_SERVER, LoggingFeature.Verbosity.PAYLOAD_ANY);
+ private static JerseyLambdaContainerHandler albHandler;
private static Context lambdaContext = new MockLambdaContext();
@@ -92,7 +104,7 @@ private AwsProxyRequestBuilder getRequestBuilder(String path, String method) {
return new AwsProxyRequestBuilder(path, method);
}
- private AwsProxyResponse executeRequest(AwsProxyRequestBuilder requestBuilder, Context lambdaContext) {
+ private AwsProxyResponseEvent executeRequest(AwsProxyRequestBuilder requestBuilder, Context lambdaContext) {
switch (type) {
case "API_GW":
if (handler == null) {
@@ -100,10 +112,10 @@ private AwsProxyResponse executeRequest(AwsProxyRequestBuilder requestBuilder, C
}
return handler.proxy(requestBuilder.build(), lambdaContext);
case "ALB":
- if (handler == null) {
- handler = JerseyLambdaContainerHandler.getAwsProxyHandler(app);
+ if (albHandler == null) {
+ albHandler = JerseyLambdaContainerHandler.getAlbProxyHandler(albApp);
}
- return handler.proxy(requestBuilder.alb().build(), lambdaContext);
+ return albHandler.proxy(requestBuilder.toAlbRequest(), lambdaContext);
case "HTTP_API":
if (httpApiHandler == null) {
httpApiHandler = JerseyLambdaContainerHandler.getHttpApiV2ProxyHandler(httpApiApp);
@@ -122,9 +134,9 @@ void queryString_uriInfo_echo(String reqType) {
.json()
.queryString(QUERY_STRING_KEY, QUERY_STRING_NON_ENCODED_VALUE);
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(200, output.getStatusCode());
- assertEquals("application/json", output.getMultiValueHeaders().getFirst("Content-Type"));
+ assertEquals("application/json", getFirst(output.getMultiValueHeaders(), "Content-Type"));
validateMapResponseModel(output, QUERY_STRING_KEY, QUERY_STRING_NON_ENCODED_VALUE);
}
@@ -137,9 +149,9 @@ void queryString_notEncoded_echo(String reqType) {
.json()
.queryString(QUERY_STRING_KEY, QUERY_STRING_NON_ENCODED_VALUE);
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(200, output.getStatusCode());
- assertEquals("application/json", output.getMultiValueHeaders().getFirst("Content-Type"));
+ assertEquals("application/json", getFirst(output.getMultiValueHeaders(), "Content-Type"));
validateMapResponseModel(output, QUERY_STRING_KEY, QUERY_STRING_NON_ENCODED_VALUE);
}
@@ -153,9 +165,9 @@ void queryString_encoded_echo(String reqType) {
.json()
.queryString(QUERY_STRING_KEY, QUERY_STRING_ENCODED_VALUE);
- AwsProxyResponse output = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent output = executeRequest(request, lambdaContext);
assertEquals(200, output.getStatusCode());
- assertEquals("application/json", output.getMultiValueHeaders().getFirst("Content-Type"));
+ assertEquals("application/json", getFirst(output.getMultiValueHeaders(), "Content-Type"));
validateMapResponseModel(output, QUERY_STRING_KEY, QUERY_STRING_NON_ENCODED_VALUE);
}
@@ -166,7 +178,7 @@ void simpleQueryParam_encoding_expectDecodedParam(String reqType) {
initJerseyParamEncodingTest(reqType);
AwsProxyRequestBuilder request = getRequestBuilder("/echo/decoded-param", "GET").queryString("param", SIMPLE_ENCODED_PARAM);
- AwsProxyResponse resp = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent resp = executeRequest(request, lambdaContext);
assertEquals(200, resp.getStatusCode());
validateSingleValueModel(resp, SIMPLE_ENCODED_PARAM);
}
@@ -177,7 +189,7 @@ void jsonQueryParam_encoding_expectDecodedParam(String reqType) {
initJerseyParamEncodingTest(reqType);
AwsProxyRequestBuilder request = getRequestBuilder("/echo/decoded-param", "GET").queryString("param", JSON_ENCODED_PARAM);
- AwsProxyResponse resp = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent resp = executeRequest(request, lambdaContext);
assertEquals(200, resp.getStatusCode());
validateSingleValueModel(resp, JSON_ENCODED_PARAM);
}
@@ -193,7 +205,7 @@ void simpleQueryParam_encoding_expectEncodedParam(String reqType) {
} catch (UnsupportedEncodingException e) {
fail("Could not encode parameter value");
}
- AwsProxyResponse resp = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent resp = executeRequest(request, lambdaContext);
assertEquals(200, resp.getStatusCode());
validateSingleValueModel(resp, encodedVal);
}
@@ -209,7 +221,7 @@ void jsonQueryParam_encoding_expectEncodedParam(String reqType) {
} catch (UnsupportedEncodingException e) {
fail("Could not encode parameter value");
}
- AwsProxyResponse resp = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent resp = executeRequest(request, lambdaContext);
assertEquals(200, resp.getStatusCode());
validateSingleValueModel(resp, encodedVal);
}
@@ -220,7 +232,7 @@ void queryParam_encoding_expectFullyEncodedUrl(String reqType) {
initJerseyParamEncodingTest(reqType);
String paramValue = "/+=";
AwsProxyRequestBuilder request = getRequestBuilder("/echo/encoded-param", "GET").queryString("param", paramValue);
- AwsProxyResponse resp = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent resp = executeRequest(request, lambdaContext);
assertNotNull(resp);
assertEquals(200, resp.getStatusCode());
validateSingleValueModel(resp, "%2F%2B%3D");
@@ -233,7 +245,7 @@ void pathParam_encoded_routesToCorrectPath(String reqType) {
String encodedParam = "http%3A%2F%2Fhelloresource.com";
String path = "/echo/encoded-path/" + encodedParam;
AwsProxyRequestBuilder request = getRequestBuilder(path, "GET");
- AwsProxyResponse resp = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent resp = executeRequest(request, lambdaContext);
assertNotNull(resp);
assertEquals(200, resp.getStatusCode());
validateSingleValueModel(resp, encodedParam);
@@ -246,7 +258,7 @@ void pathParam_encoded_returns404(String reqType) {
String encodedParam = "http://helloresource.com";
String path = "/echo/encoded-path/" + encodedParam;
AwsProxyRequestBuilder request = getRequestBuilder(path, "GET");
- AwsProxyResponse resp = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent resp = executeRequest(request, lambdaContext);
assertNotNull(resp);
assertEquals(404, resp.getStatusCode());
}
@@ -257,7 +269,7 @@ void pathParam_encoded_returns404(String reqType) {
void queryParam_listOfString_expectCorrectLength(String reqType) {
initJerseyParamEncodingTest(reqType);
AwsProxyRequestBuilder request = getRequestBuilder("/echo/list-query-string", "GET").queryString("list", "v1,v2,v3");
- AwsProxyResponse resp = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent resp = executeRequest(request, lambdaContext);
assertNotNull(resp);
assertEquals(200, resp.getStatusCode());
validateSingleValueModel(resp, "3");
@@ -270,13 +282,13 @@ void multipart_getFileSize_expectCorrectLength(String reqType)
initJerseyParamEncodingTest(reqType);
AwsProxyRequestBuilder request = getRequestBuilder("/echo/file-size", "POST")
.formFilePart("file", "myfile.jpg", FILE_CONTENTS);
- AwsProxyResponse resp = executeRequest(request, lambdaContext);
+ AwsProxyResponseEvent resp = executeRequest(request, lambdaContext);
assertNotNull(resp);
assertEquals(200, resp.getStatusCode());
validateSingleValueModel(resp, "" + FILE_CONTENTS.length);
}
- private void validateSingleValueModel(AwsProxyResponse output, String value) {
+ private void validateSingleValueModel(AwsProxyResponseEvent output, String value) {
try {
SingleValueModel response = objectMapper.readValue(output.getBody(), SingleValueModel.class);
assertNotNull(response.getValue());
@@ -287,7 +299,7 @@ private void validateSingleValueModel(AwsProxyResponse output, String value) {
}
}
- private void validateMapResponseModel(AwsProxyResponse output, String key, String value) {
+ private void validateMapResponseModel(AwsProxyResponseEvent output, String key, String value) {
try {
MapResponseModel response = objectMapper.readValue(output.getBody(), MapResponseModel.class);
assertNotNull(response.getValues().get(key));
diff --git a/aws-serverless-java-container-spark/src/main/java/com/amazonaws/serverless/proxy/spark/SparkLambdaContainerHandler.java b/aws-serverless-java-container-spark/src/main/java/com/amazonaws/serverless/proxy/spark/SparkLambdaContainerHandler.java
index 9c1b47511..8db251aef 100644
--- a/aws-serverless-java-container-spark/src/main/java/com/amazonaws/serverless/proxy/spark/SparkLambdaContainerHandler.java
+++ b/aws-serverless-java-container-spark/src/main/java/com/amazonaws/serverless/proxy/spark/SparkLambdaContainerHandler.java
@@ -119,7 +119,7 @@ public static SparkLambdaContainerHandler get
}
/**
- * Returns a new instance of an SparkLambdaContainerHandler initialized to work with HttpApiV2ProxyRequest
+ * Returns a new instance of an SparkLambdaContainerHandler initialized to work with APIGatewayV2HTTPEvent
* and AwsProxyResponse
objects.
*
* @return a new instance of SparkLambdaContainerHandler
@@ -127,9 +127,9 @@ public static SparkLambdaContainerHandler get
* @throws ContainerInitializationException Throws this exception if we fail to initialize the Spark container.
* This could be caused by the introspection used to insert the library as the default embedded container
*/
- public static SparkLambdaContainerHandler getHttpApiV2ProxyHandler()
+ public static SparkLambdaContainerHandler getHttpApiV2ProxyHandler()
throws ContainerInitializationException {
- SparkLambdaContainerHandler newHandler = new SparkLambdaContainerHandler<>(HttpApiV2ProxyRequest.class,
+ SparkLambdaContainerHandler newHandler = new SparkLambdaContainerHandler<>(APIGatewayV2HTTPEvent.class,
AwsProxyResponse.class,
new AwsHttpApiV2HttpServletRequestReader(),
new AwsProxyHttpServletResponseWriter(true),
diff --git a/aws-serverless-java-container-spark/src/test/java/com/amazonaws/serverless/proxy/spark/HelloWorldSparkStreamTest.java b/aws-serverless-java-container-spark/src/test/java/com/amazonaws/serverless/proxy/spark/HelloWorldSparkStreamTest.java
index 33bc19f1d..bece71fac 100644
--- a/aws-serverless-java-container-spark/src/test/java/com/amazonaws/serverless/proxy/spark/HelloWorldSparkStreamTest.java
+++ b/aws-serverless-java-container-spark/src/test/java/com/amazonaws/serverless/proxy/spark/HelloWorldSparkStreamTest.java
@@ -8,7 +8,6 @@
import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
-import com.amazonaws.serverless.proxy.model.HttpApiV2ProxyRequest;
import com.amazonaws.services.lambda.runtime.Context;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.params.ParameterizedTest;
@@ -39,7 +38,7 @@ public class HelloWorldSparkStreamTest {
private static final String COOKIE_PATH = "/";
private static SparkLambdaContainerHandler handler;
- private static SparkLambdaContainerHandler httpApiHandler;
+ private static SparkLambdaContainerHandler httpApiHandler;
private String type;
diff --git a/aws-serverless-java-container-spring/src/main/java/com/amazonaws/serverless/proxy/spring/SpringLambdaContainerHandler.java b/aws-serverless-java-container-spring/src/main/java/com/amazonaws/serverless/proxy/spring/SpringLambdaContainerHandler.java
index 5e56dba62..4f6787075 100644
--- a/aws-serverless-java-container-spring/src/main/java/com/amazonaws/serverless/proxy/spring/SpringLambdaContainerHandler.java
+++ b/aws-serverless-java-container-spring/src/main/java/com/amazonaws/serverless/proxy/spring/SpringLambdaContainerHandler.java
@@ -15,11 +15,12 @@
import com.amazonaws.serverless.exceptions.ContainerInitializationException;
import com.amazonaws.serverless.proxy.*;
import com.amazonaws.serverless.proxy.internal.testutils.Timer;
-import com.amazonaws.serverless.proxy.model.AwsProxyRequest;
-import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
import com.amazonaws.serverless.proxy.internal.servlet.*;
-import com.amazonaws.serverless.proxy.model.HttpApiV2ProxyRequest;
import com.amazonaws.services.lambda.runtime.Context;
+import com.amazonaws.services.lambda.runtime.events.ApplicationLoadBalancerRequestEvent;
+import com.amazonaws.services.lambda.runtime.events.AwsProxyResponseEvent;
+import com.amazonaws.services.lambda.runtime.events.apigateway.APIGatewayProxyRequestEvent;
+import com.amazonaws.services.lambda.runtime.events.apigateway.APIGatewayV2HTTPEvent;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
@@ -44,13 +45,13 @@ public class SpringLambdaContainerHandler extends Aws
private boolean refreshContext = false;
/**
- * Creates a default SpringLambdaContainerHandler initialized with the `AwsProxyRequest` and `AwsProxyResponse` objects
+ * Creates a default SpringLambdaContainerHandler initialized with the `APIGatewayProxyRequestEvent` and `AwsProxyResponse` objects
* @param config A set of classes annotated with the Spring @Configuration annotation
* @return An initialized instance of the `SpringLambdaContainerHandler`
* @throws ContainerInitializationException When the Spring framework fails to start.
*/
- public static SpringLambdaContainerHandler getAwsProxyHandler(Class>... config) throws ContainerInitializationException {
- return new SpringProxyHandlerBuilder()
+ public static SpringLambdaContainerHandler getAwsProxyHandler(Class>... config) throws ContainerInitializationException {
+ return new SpringProxyHandlerBuilder()
.defaultProxy()
.initializationWrapper(new InitializationWrapper())
.configurationClasses(config)
@@ -58,15 +59,15 @@ public static SpringLambdaContainerHandler ge
}
/**
- * Creates a default SpringLambdaContainerHandler initialized with the `AwsProxyRequest` and `AwsProxyResponse` objects and sets the given profiles as active
+ * Creates a default SpringLambdaContainerHandler initialized with the `APIGatewayProxyRequestEvent` and `AwsProxyResponse` objects and sets the given profiles as active
* @param applicationContext A custom ConfigurableWebApplicationContext to be used
* @param profiles The spring profiles to activate
* @return An initialized instance of the `SpringLambdaContainerHandler`
* @throws ContainerInitializationException When the Spring framework fails to start.
*/
- public static SpringLambdaContainerHandler getAwsProxyHandler(ConfigurableWebApplicationContext applicationContext, String... profiles)
+ public static SpringLambdaContainerHandler getAwsProxyHandler(ConfigurableWebApplicationContext applicationContext, String... profiles)
throws ContainerInitializationException {
- return new SpringProxyHandlerBuilder()
+ return new SpringProxyHandlerBuilder()
.defaultProxy()
.initializationWrapper(new InitializationWrapper())
.springApplicationContext(applicationContext)
@@ -80,14 +81,22 @@ public static SpringLambdaContainerHandler ge
* @return An initialized instance of the `SpringLambdaContainerHandler`
* @throws ContainerInitializationException When the Spring framework fails to start.
*/
- public static SpringLambdaContainerHandler getHttpApiV2ProxyHandler(Class>... config) throws ContainerInitializationException {
- return new SpringProxyHandlerBuilder()
+ public static SpringLambdaContainerHandler getHttpApiV2ProxyHandler(Class>... config) throws ContainerInitializationException {
+ return new SpringProxyHandlerBuilder()
.defaultHttpApiV2Proxy()
.initializationWrapper(new InitializationWrapper())
.configurationClasses(config)
.buildAndInitialize();
}
+ public static SpringLambdaContainerHandler getAlbProxyHandler(Class>... config) throws ContainerInitializationException {
+ return new SpringProxyHandlerBuilder()
+ .defaultAlbProxy()
+ .initializationWrapper(new InitializationWrapper())
+ .configurationClasses(config)
+ .buildAndInitialize();
+ }
+
/**
* Creates a new container handler with the given reader and writer objects
*
diff --git a/aws-serverless-java-container-spring/src/main/java/com/amazonaws/serverless/proxy/spring/SpringProxyHandlerBuilder.java b/aws-serverless-java-container-spring/src/main/java/com/amazonaws/serverless/proxy/spring/SpringProxyHandlerBuilder.java
index 5614b94df..5a6f74214 100644
--- a/aws-serverless-java-container-spring/src/main/java/com/amazonaws/serverless/proxy/spring/SpringProxyHandlerBuilder.java
+++ b/aws-serverless-java-container-spring/src/main/java/com/amazonaws/serverless/proxy/spring/SpringProxyHandlerBuilder.java
@@ -14,7 +14,7 @@
import com.amazonaws.serverless.exceptions.ContainerInitializationException;
import com.amazonaws.serverless.proxy.internal.servlet.ServletLambdaContainerHandlerBuilder;
-import com.amazonaws.serverless.proxy.model.AwsProxyResponse;
+import com.amazonaws.services.lambda.runtime.events.AwsProxyResponseEvent;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
@@ -22,9 +22,9 @@
public class SpringProxyHandlerBuilder extends ServletLambdaContainerHandlerBuilder<
RequestType,
- AwsProxyResponse,
+ AwsProxyResponseEvent,
HttpServletRequest,
- SpringLambdaContainerHandler,
+ SpringLambdaContainerHandler,
SpringProxyHandlerBuilder> {
private ConfigurableWebApplicationContext springContext;
private Class[] configurationClasses;
@@ -52,7 +52,7 @@ public SpringProxyHandlerBuilder profiles(String... profiles) {
}
@Override
- public SpringLambdaContainerHandler build() throws ContainerInitializationException {
+ public SpringLambdaContainerHandler build() throws ContainerInitializationException {
validate();
if (springContext == null && (configurationClasses == null || configurationClasses.length == 0)) {
throw new ContainerInitializationException("Missing both configuration classes and application context, at least" +
@@ -66,14 +66,14 @@ public SpringLambdaContainerHandler build() throw
}
}
- SpringLambdaContainerHandler handler = createHandler(ctx);
+ SpringLambdaContainerHandler handler = createHandler(ctx);
if (profiles != null) {
handler.activateSpringProfiles(profiles);
}
return handler;
}
- protected SpringLambdaContainerHandler createHandler(ConfigurableWebApplicationContext ctx) {
+ protected SpringLambdaContainerHandler createHandler(ConfigurableWebApplicationContext ctx) {
return new SpringLambdaContainerHandler<>(
requestTypeClass, responseTypeClass, requestReader, responseWriter,
securityContextWriter, exceptionHandler, ctx, initializationWrapper
@@ -81,8 +81,8 @@ protected SpringLambdaContainerHandler