From b00360dff1402e0d65b16acb93838283c8e70447 Mon Sep 17 00:00:00 2001 From: Kazumasa <49652236+goro9@users.noreply.github.com> Date: Fri, 3 May 2024 20:34:41 +0900 Subject: [PATCH] use timeout context in webhook as well (#5) --- handler.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/handler.go b/handler.go index be06818..3751c04 100644 --- a/handler.go +++ b/handler.go @@ -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(