diff --git a/sample-functions/WebhookStash/handler.go b/sample-functions/WebhookStash/handler.go index 5e41b6b1..f2a0516f 100644 --- a/sample-functions/WebhookStash/handler.go +++ b/sample-functions/WebhookStash/handler.go @@ -6,13 +6,23 @@ import ( "os" "strconv" "time" + "log" ) func main() { - input, _ := ioutil.ReadAll(os.Stdin) - fmt.Println("Stashing request") + input, err := ioutil.ReadAll(os.Stdin) + if err != nil { + log.Fatalf("Cannot read input %s.\n", err) + return + } now := time.Now() stamp := strconv.FormatInt(now.UnixNano(), 10) - ioutil.WriteFile(stamp+".txt", input, 0644) + writeErr := ioutil.WriteFile(stamp+".txt", input, 0644) + if writeErr != nil { + log.Fatalf("Cannot write input %s.\n", err) + return + } + + fmt.Printf("Stashing request: %s.txt\n", stamp) }