Java classes for AWS Lambda Proxy Integration

When I had to configure Lambda Proxy Integrations in AWS API Gateway for the second time for a week I thought about extracting Java classes in a small library for later reuse.

I have even made one and used it for about half of year until it turned out that the classes I need already exist in com.amazonaws:aws-lambda-java-events artifact: APIGatewayProxyRequestEvent and APIGatewayProxyResponseEvent:

repositories {
  jcenter()
}

dependencies {
  implementation("com.amazonaws:aws-lambda-java-events:2.2.6")
}
public class Handler implements Handler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> {
    @Override
    public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEvent input, final Context context) {
        return new APIGatewayProxyResponseEvent()
                .withStatusCode(200)
                .withHeaders(Collections.emptyMap())
                .withBody("{\"input\":\"" + input.getBody() + "\"}");
    }
}
comments powered by Disqus