forked from anomalyco/sst
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget.go
More file actions
31 lines (25 loc) · 646 Bytes
/
Copy pathget.go
File metadata and controls
31 lines (25 loc) · 646 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 (
"encoding/json"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/serverless-stack/examples/rest-api-go/db"
)
func Handler(request events.APIGatewayV2HTTPRequest) (events.APIGatewayProxyResponse, error) {
var notes = db.Notes()
var note = notes[request.PathParameters["id"]]
if note == nil {
return events.APIGatewayProxyResponse{
Body: `{"error":true}`,
StatusCode: 404,
}, nil
}
response, _ := json.Marshal(note)
return events.APIGatewayProxyResponse{
Body: string(response),
StatusCode: 200,
}, nil
}
func main() {
lambda.Start(Handler)
}