Skip to content

Commit ac2f18e

Browse files
ppai-plivobmoffatt
andauthored
events: Add working example for CloudWatch Events (#375)
* events: Add working example for CloudWatch Events Signed-off-by: Prashanth Pai <[email protected]> * Update README_CloudWatch_Events.md removed extra empty line Co-authored-by: Bryan Moffatt <[email protected]>
1 parent 250c0d5 commit ac2f18e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

events/README_CloudWatch_Events.md

+21
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,24 @@ func handler(ctx context.Context, event events.CloudWatchEvent) {
1515
fmt.Printf("Detail = %s\n", event.Detail)
1616
}
1717
```
18+
19+
## CloudWatch Scheduled Events
20+
21+
If you have a constant JSON text in a CloudWatch Scheduled Event, it can be accessed either by explicitly defining a structure for the json payload you would expect:
22+
23+
```go
24+
type MyRequest struct {
25+
Name string `json:"name"`
26+
}
27+
28+
func handler(ctx context.Context, req MyRequest) {
29+
}
30+
```
31+
32+
or by accepting raw json blob as is:
33+
34+
```go
35+
func handler(ctx context.Context, b json.RawMessage) {
36+
// json.RawMessage is basically []byte which can be unmarshalled
37+
}
38+
```

0 commit comments

Comments
 (0)