Skip to content

Instantly share code, notes, and snippets.

Created Apr 11, 2022
What would you like to do?
package com.serverless;
import com.serverless.dal.Product;
public class ListProductsHandler implements RequestHandler<Map<String, Object>, ApiGatewayResponse> {
private final Logger logger = Logger.getLogger(this.getClass());
public ApiGatewayResponse handleRequest(Map<String, Object> input, Context context) {
try {
// get all products
List<Product> products = new Product().list();
// send the response back
return ApiGatewayResponse.builder()
.setHeaders(Collections.singletonMap("X-Powered-By", "AWS Lambda & Serverless"))
} catch (Exception ex) {
logger.error("Error in listing products: " + ex);
// send the error response back
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment