@@ -8,20 +8,29 @@ The following is a sample class and Lambda function that receives Amazon API Gat
8
8
9
9
``` go
10
10
11
+ package main
12
+
11
13
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"
14
19
)
15
20
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 ))
19
24
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
+ }
24
32
25
- return ApiGatewayProxyResponse { Body: request.Body , StatusCode: 200 }
33
+ func main () {
34
+ lambda.Start (handleRequest)
26
35
}
27
36
```
0 commit comments