diff --git a/pkg/webhook/webhook.go b/pkg/webhook/webhook.go index 493f5b0..9859177 100644 --- a/pkg/webhook/webhook.go +++ b/pkg/webhook/webhook.go @@ -33,6 +33,10 @@ func SetHTTPClient(c *http.Client) { client = c } +func isResponseOK(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() @@ -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 !isResponseOK(resp.StatusCode) { return errors.Wrap(errHTTPNotOK, fmt.Sprintf("StatusCode=%d", resp.StatusCode)) }