mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-23 16:58:31 +02:00
add timeout to notification context
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
E "github.com/yusing/go-proxy/internal/error"
|
E "github.com/yusing/go-proxy/internal/error"
|
||||||
gphttp "github.com/yusing/go-proxy/internal/net/http"
|
gphttp "github.com/yusing/go-proxy/internal/net/http"
|
||||||
@@ -40,6 +41,10 @@ func notifyProvider(ctx context.Context, provider Provider, msg *LogMessage) err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return E.PrependSubject(provider.GetName(), err)
|
return E.PrependSubject(provider.GetName(), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
req, err := http.NewRequestWithContext(
|
req, err := http.NewRequestWithContext(
|
||||||
ctx,
|
ctx,
|
||||||
http.MethodPost,
|
http.MethodPost,
|
||||||
|
|||||||
Reference in New Issue
Block a user