37 lines
871 B
Go
37 lines
871 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/aws/aws-lambda-go/events"
|
|
"github.com/aws/aws-lambda-go/lambda"
|
|
"github.com/gjcampbell777/personal_site/backend-go/internal/crud"
|
|
"github.com/gjcampbell777/personal_site/backend-go/internal/database"
|
|
)
|
|
|
|
func handler(ctx context.Context, req events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
|
|
client := database.NewClient()
|
|
payload := crud.Health(client)
|
|
body, err := json.Marshal(payload)
|
|
if err != nil {
|
|
return events.APIGatewayProxyResponse{
|
|
StatusCode: http.StatusInternalServerError,
|
|
Body: "failed to encode response",
|
|
}, nil
|
|
}
|
|
|
|
return events.APIGatewayProxyResponse{
|
|
StatusCode: http.StatusOK,
|
|
Headers: map[string]string{
|
|
"Content-Type": "application/json",
|
|
},
|
|
Body: string(body),
|
|
}, nil
|
|
}
|
|
|
|
func main() {
|
|
lambda.Start(handler)
|
|
}
|