Skip to content

Commit

Permalink
Identify webhook result http 2xx as OK (#95)
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Paskal <[email protected]>
  • Loading branch information
maksim-paskal authored Dec 20, 2024
1 parent 32b0023 commit 96d50f2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ func SetHTTPClient(c *retryablehttp.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 @@ -86,7 +90,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

0 comments on commit 96d50f2

Please sign in to comment.