in source/src/main/java/com/amazonaws/comprehend/esproxy/lambda/OpenSearchServiceProxyRequestHandler.java [74:98]
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent requestEvent, Context context) {
LambdaLogger logger = context.getLogger();
logger.log("Received API Gateway request event");
try {
// Transform API Gateway request to OpenSearch Service request
Request esRequest = HTTPTransformer.apiGatewayRequestToESRequest(requestEvent);
OpenSearchServiceProcessor openSearchServiceProcessor = getProcessor(esRequest);
Response esConfigResponse = openSearchServiceProcessor.processRequest(esRequest, logger);
return HTTPTransformer.esResponseToAPIGatewayResponse(esConfigResponse);
} catch (InvalidRequestException e) {
logger.log("Received InvalidRequestException when processing request");
logger.log(Arrays.toString(e.getStackTrace()));
return new APIGatewayProxyResponseEvent()
.withBody(e.getMessage())
.withStatusCode(HttpStatus.SC_BAD_REQUEST);
} catch (Exception e) {
logger.log("Received InternalErrorException when processing request");
logger.log(Arrays.toString(e.getStackTrace()));
return new APIGatewayProxyResponseEvent()
.withBody(e.getMessage())
.withStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
}