Skip to content

Commit 41c45fa

Browse files
authored
Merge pull request aws#4 from joonhochoi/moddoc
Change to working sample code
2 parents 28a6e9f + d578878 commit 41c45fa

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

events/README_ApiGatewayEvent.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,29 @@ The following is a sample class and Lambda function that receives Amazon API Gat
88

99
```go
1010

11+
package main
12+
1113
import (
12-
"strings"
13-
"github.com/aws/aws-lambda-go/events"
14+
"context"
15+
"fmt"
16+
17+
"github.com/aws/aws-lambda-go/events"
18+
"github.com/aws/aws-lambda-go/lambda"
1419
)
1520

16-
func handleRequest(ctx context.Context, request events.ApiGatewayProxyRequest) events.ApiGatewayProxyResponse {
17-
fmt.Printf("Processing request data for request %s.\n", request.RequestContext.RequestId)
18-
fmt.Printf("Body size = %d.\n", len(request.Body))
21+
func handleRequest(ctx context.Context, request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
22+
fmt.Printf("Processing request data for request %s.\n", request.RequestContext.RequestID)
23+
fmt.Printf("Body size = %d.\n", len(request.Body))
1924

20-
fmt.Println("Headers:")
21-
for key, value := range request.Headers {
22-
fmt.Printf(" %s: %s\n", key, value)
23-
}
25+
fmt.Println("Headers:")
26+
for key, value := range request.Headers {
27+
fmt.Printf(" %s: %s\n", key, value)
28+
}
29+
30+
return events.APIGatewayProxyResponse{Body: request.Body, StatusCode: 200}, nil
31+
}
2432

25-
return ApiGatewayProxyResponse { Body: request.Body, StatusCode: 200 }
33+
func main() {
34+
lambda.Start(handleRequest)
2635
}
2736
```

0 commit comments

Comments
 (0)