forked from snsinfu/terraform-lambda-example
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
31 lines (26 loc) · 716 Bytes
/
main.go
File metadata and controls
31 lines (26 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"fmt"
"net/http"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
// The input type and the output type are defined by the API Gateway.
func handleRequest(req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
name, ok := req.QueryStringParameters["name"]
if !ok {
res := events.APIGatewayProxyResponse{
StatusCode: http.StatusBadRequest,
}
return res, nil
}
res := events.APIGatewayProxyResponse{
StatusCode: http.StatusOK,
Headers: map[string]string{"Content-Type": "text/plain; charset=utf-8"},
Body: fmt.Sprintf("Hello, %s!\n", name),
}
return res, nil
}
func main() {
lambda.Start(handleRequest)
}