-
-
Save Aleksandr-Filichkin/440bb40c4872b5adea86dda34e899bdb to your computer and use it in GitHub Desktop.
Version 1 Java lambda handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BookHandler implements RequestHandler<APIGatewayProxyRequestEvent, APIGatewayProxyResponseEvent> { | |
private static final String TABLE_NAME = "books"; | |
private final RequestDispatcher requestDispatcher; | |
public BookHandler() { | |
DynamoDbEnhancedClient dynamoDbEnhancedClient = DynamoDbEnhancedClient.create(); | |
DynamoDbTable<Book> dynamoDbTable = dynamoDbEnhancedClient.table(TABLE_NAME, TableSchema.fromBean(Book.class)); | |
requestDispatcher = new RequestDispatcher(new EnhancedClientBookStorage(dynamoDbTable), new ObjectMapper()); | |
} | |
@Override | |
public APIGatewayProxyResponseEvent handleRequest(APIGatewayProxyRequestEvent apiGatewayProxyRequestEvent, Context context) { | |
return requestDispatcher.dispatch(apiGatewayProxyRequestEvent); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment