Skip to content

Commit

Permalink
use timeout context in webhook as well (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
goro9 authored May 3, 2024
1 parent 2e35f73 commit b00360d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,13 @@ func (h *SlackHandler) WithGroup(name string) slog.Handler {
}

func (h *SlackHandler) postMessage(message *slack.WebhookMessage) error {
if h.option.WebhookURL != "" {
return slack.PostWebhook(h.option.WebhookURL, message)
}

ctx, cancel := context.WithTimeout(context.Background(), h.option.Timeout)
defer cancel()

if h.option.WebhookURL != "" {
return slack.PostWebhookContext(ctx, h.option.WebhookURL, message)
}

_, _, err := slack.
New(h.option.BotToken).
PostMessageContext(
Expand Down

0 comments on commit b00360d

Please sign in to comment.