DeleteItem request

Finally, in order to delete an item from DynamoDB, the following Lambda function should be implemented:

  1. Register a new handler to delete a movie. The handler will encode the payload in the request body to a Movie struct:
var movie Movieerr := json.Unmarshal([]byte(request.Body), &movie)if err != nil {   return events.APIGatewayProxyResponse{      StatusCode: 400,      Body: "Invalid payload",   }, nil}
  1. Then, call the DeleteItem method with the movie ID as a parameter to remove it from the table:
cfg, err := external.LoadDefaultAWSConfig()if err != nil {  return events.APIGatewayProxyResponse{    StatusCode: http.StatusInternalServerError,    Body: "Error while retrieving AWS credentials",  }, nil}svc := dynamodb.New(cfg)req := svc.DeleteItemRequest(&dynamodb.DeleteItemInput{ ...

Get Hands-On Serverless Applications with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.