Create REST operation to create a new Product
Create REST Operation to Create a New Product
- Open the file ApiStack.java. Within the createProductsResource method, use the addMethod function to create a PUT method for the productsResource resource.
productsResource.addMethod("POST");

- Next, we will define an Integration to handle POST requests to the endpoint /products. This part is similar to the GET integration, but we just need to specify integrationHttpMethod(“POST”).
productsResource.addMethod("POST", new Integration(
IntegrationProps.builder()
.type(IntegrationType.HTTP_PROXY)
.integrationHttpMethod("POST")
.uri("http://" + apiStackProps.networkLoadBalancer().getLoadBalancerDnsName() +
":8081/api/products")
.options(IntegrationOptions.builder()
.vpcLink(apiStackProps.vpcLink())
.connectionType(ConnectionType.VPC_LINK)
.build())
.build()));
