diff --git a/events/README_ApiGatewayEvent.md b/events/README_ApiGatewayEvent.md index 1a86c30c..65ceabce 100644 --- a/events/README_ApiGatewayEvent.md +++ b/events/README_ApiGatewayEvent.md @@ -8,20 +8,29 @@ The following is a sample class and Lambda function that receives Amazon API Gat ```go +package main + import ( - "strings" - "github.com/aws/aws-lambda-go/events" + "context" + "fmt" + + "github.com/aws/aws-lambda-go/events" + "github.com/aws/aws-lambda-go/lambda" ) -func handleRequest(ctx context.Context, request events.ApiGatewayProxyRequest) events.ApiGatewayProxyResponse { - fmt.Printf("Processing request data for request %s.\n", request.RequestContext.RequestId) - fmt.Printf("Body size = %d.\n", len(request.Body)) +func handleRequest(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) { + fmt.Printf("Processing request data for request %s.\n", request.RequestContext.RequestID) + fmt.Printf("Body size = %d.\n", len(request.Body)) - fmt.Println("Headers:") - for key, value := range request.Headers { - fmt.Printf(" %s: %s\n", key, value) - } + fmt.Println("Headers:") + for key, value := range request.Headers { + fmt.Printf(" %s: %s\n", key, value) + } + + return events.APIGatewayProxyResponse{Body: request.Body, StatusCode: 200}, nil +} - return ApiGatewayProxyResponse { Body: request.Body, StatusCode: 200 } +func main() { + lambda.Start(handleRequest) } ```