Skip to content

Instantly share code, notes, and snippets.

@Aleksandr-Filichkin
Last active August 11, 2021 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aleksandr-Filichkin/440bb40c4872b5adea86dda34e899bdb to your computer and use it in GitHub Desktop.
Save Aleksandr-Filichkin/440bb40c4872b5adea86dda34e899bdb to your computer and use it in GitHub Desktop.
Version 1 Java lambda handler
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