1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package component
import (
"crypto/tls"
"log/slog"
"net/http"
"time"
"github.com/johnandersen777/socialweb-computer-kcp/internal/kit/httpclient"
)
type Egress struct {
Hosts NetworkHosts
TLS *tls.Config
Log *slog.Logger
}
func (e Egress) Client(timeout time.Duration) *http.Client {
return httpclient.External(httpclient.Options{
Timeout: timeout,
Hosts: e.Hosts,
TLS: e.TLS,
OnError: func(err error) {
if e.Log != nil {
e.Log.Warn("the external HTTP transport is not configured", "err", err)
}
},
})
}