RequestType - The request object used by the RequestReader implementation passed to the constructorResponseType - The response object produced by the ResponseWriter implementation in the constructorpublic class SparkLambdaContainerHandler<RequestType,ResponseType> extends LambdaContainerHandler<RequestType,ResponseType,AwsProxyHttpServletRequest,AwsHttpServletResponse>
LambdaContainerHandler object that supports the Spark framework: http://sparkjava.com/
Because of the way this container is implemented, using reflection to change accessibility of methods in the Spark
framework and inserting itself as the default embedded container, it is important that you initialize the Handler
before declaring your spark routes.
This implementation uses the default AwsProxyHttpServletRequest and Response implementations.
// always initialize the handler first
SparkLambdaContainerHandler<AwsProxyRequest, AwsProxyResponse> handler =
SparkLambdaContainerHandler.getAwsProxyHandler();
get("/hello", (req, res) -> {
res.status(200);
res.body("Hello World");
});
| Constructor and Description |
|---|
SparkLambdaContainerHandler(RequestReader<RequestType,AwsProxyHttpServletRequest> requestReader,
ResponseWriter<AwsHttpServletResponse,ResponseType> responseWriter,
SecurityContextWriter<RequestType> securityContextWriter,
ExceptionHandler<ResponseType> exceptionHandler) |
| Modifier and Type | Method and Description |
|---|---|
static SparkLambdaContainerHandler<AwsProxyRequest,AwsProxyResponse> |
getAwsProxyHandler()
Returns a new instance of an SparkLambdaContainerHandler initialized to work with
AwsProxyRequest
and AwsProxyResponse objects. |
protected AwsHttpServletResponse |
getContainerResponse(java.util.concurrent.CountDownLatch latch) |
protected void |
handleRequest(AwsProxyHttpServletRequest httpServletRequest,
AwsHttpServletResponse httpServletResponse,
com.amazonaws.services.lambda.runtime.Context lambdaContext) |
proxypublic SparkLambdaContainerHandler(RequestReader<RequestType,AwsProxyHttpServletRequest> requestReader, ResponseWriter<AwsHttpServletResponse,ResponseType> responseWriter, SecurityContextWriter<RequestType> securityContextWriter, ExceptionHandler<ResponseType> exceptionHandler) throws ContainerInitializationException
ContainerInitializationExceptionpublic static SparkLambdaContainerHandler<AwsProxyRequest,AwsProxyResponse> getAwsProxyHandler() throws ContainerInitializationException
AwsProxyRequest
and AwsProxyResponse objects.SparkLambdaContainerHandlerContainerInitializationException - 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 containerprotected AwsHttpServletResponse getContainerResponse(java.util.concurrent.CountDownLatch latch)
getContainerResponse in class LambdaContainerHandler<RequestType,ResponseType,AwsProxyHttpServletRequest,AwsHttpServletResponse>protected void handleRequest(AwsProxyHttpServletRequest httpServletRequest, AwsHttpServletResponse httpServletResponse, com.amazonaws.services.lambda.runtime.Context lambdaContext) throws java.lang.Exception
handleRequest in class LambdaContainerHandler<RequestType,ResponseType,AwsProxyHttpServletRequest,AwsHttpServletResponse>java.lang.ExceptionCopyright © 2017. All Rights Reserved.