Skip to content

Commit

Permalink
Update the trigger EventSub code to use colors
Browse files Browse the repository at this point in the history
Output both the body and status code in a debug display for the user
  • Loading branch information
BarryCarlyon authored Sep 19, 2021
1 parent f5e790a commit ef71e6f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/events/trigger/trigger_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,13 @@ func Fire(p TriggerParameters) (string, error) {
}
defer resp.Body.Close()

log.Println(fmt.Sprintf(`[%v] Request Sent`, resp.StatusCode))
if resp.StatusCode >= 200 && resp.StatusCode <= 299 {
color.New().Add(color.FgGreen).Println(fmt.Sprintf(`✔ Request Sent. Recieved Status Code: %v`, resp.StatusCode))
color.New().Add(color.FgGreen).Println(fmt.Sprintf(`✔ Server Said: %s`, resp.Body))
} else {
color.New().Add(color.FgRed).Println(fmt.Sprintf(`✗ Invalid response. Recieved Status Code: %v`, resp.StatusCode))
color.New().Add(color.FgRed).Println(fmt.Sprintf(`✗ Server Said: %s`, resp.Body))
}
}

return string(resp.JSON), nil
Expand Down

0 comments on commit ef71e6f

Please sign in to comment.