-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
37 lines (31 loc) · 924 Bytes
/
main.go
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
32
33
34
35
36
37
package main
import (
"context"
"encoding/json"
"log"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
// HealthResponse struct defines the response structure
type HealthResponse struct {
Status string `json:"status"`
}
// Handler is the Lambda function handler
func Handler(_ context.Context) (events.APIGatewayProxyResponse, error) {
// Create a response
responseBody, err := json.Marshal(HealthResponse{Status: "healthy"})
if err != nil {
log.Printf("Error marshaling JSON response: %v", err)
return events.APIGatewayProxyResponse{StatusCode: 500, Body: `{"error":"Internal Server Error"}`}, nil
}
// Return API Gateway response
return events.APIGatewayProxyResponse{
StatusCode: 200,
Headers: map[string]string{"Content-Type": "application/json"},
Body: string(responseBody),
}, nil
}
func main() {
// Start the Lambda handler
lambda.Start(Handler)
}