From 9e0fe7be14b1dc1c22e9e86fc8434e89a2188d9e Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Tue, 18 May 2021 16:36:20 +0530 Subject: [PATCH 1/2] events: Add working example for CloudWatch Events Signed-off-by: Prashanth Pai --- events/README_CloudWatch_Events.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/events/README_CloudWatch_Events.md b/events/README_CloudWatch_Events.md index 2c6bb53b..28770363 100644 --- a/events/README_CloudWatch_Events.md +++ b/events/README_CloudWatch_Events.md @@ -15,3 +15,26 @@ func handler(ctx context.Context, event events.CloudWatchEvent) { fmt.Printf("Detail = %s\n", event.Detail) } ``` + +## CloudWatch Scheduled Events + +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: + +```go +type MyRequest struct { + Name string `json:"name"` +} + +func handler(ctx context.Context, req MyRequest) { +} +``` + +or by accepting raw json blob as is: + +```go +func handler(ctx context.Context, b json.RawMessage) { + // json.RawMessage is basically []byte which can be unmarshalled +} +``` From c354cd1daa1cc75f6c9e1b81ba3b0f58791c74fa Mon Sep 17 00:00:00 2001 From: Bryan Moffatt Date: Fri, 17 Sep 2021 17:10:43 -0700 Subject: [PATCH 2/2] Update README_CloudWatch_Events.md removed extra empty line --- events/README_CloudWatch_Events.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/events/README_CloudWatch_Events.md b/events/README_CloudWatch_Events.md index 28770363..b1d16dc7 100644 --- a/events/README_CloudWatch_Events.md +++ b/events/README_CloudWatch_Events.md @@ -18,9 +18,7 @@ func handler(ctx context.Context, event events.CloudWatchEvent) { ## CloudWatch Scheduled Events -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: +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: ```go type MyRequest struct {