Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pkg/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ func SetHTTPClient(c *http.Client) {
client = c
}

func isResponseStatusOK(statusCode int) bool {
return statusCode >= 200 && statusCode < 300
}

func SendWebHook(ctx context.Context, obj *template.MessageType) error {
ctx, cancel := context.WithTimeout(ctx, *config.Get().WebHookTimeout)
defer cancel()
Expand Down Expand Up @@ -85,7 +89,7 @@ func SendWebHook(ctx context.Context, obj *template.MessageType) error {

log.Infof("response status: %s", resp.Status)

if resp.StatusCode != http.StatusOK {
if !isResponseStatusOK(resp.StatusCode) {
return errors.Wrap(errHTTPNotOK, fmt.Sprintf("StatusCode=%d", resp.StatusCode))
}

Expand Down
Loading