-
Notifications
You must be signed in to change notification settings - Fork 12
/
client.go
37 lines (31 loc) · 892 Bytes
/
client.go
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
30
31
32
33
34
35
36
37
/*
Copyright (C) 2021-2023, Kubefirst
This program is licensed under MIT.
See the LICENSE file for more details.
*/
package httpCommon
import (
"crypto/tls"
"net/http"
"time"
)
// CustomHttpClient - creates a http client based on k1 standards
// allowInsecure defines: tls.Config{InsecureSkipVerify: allowInsecure}
func CustomHttpClient(allowInsecure bool) *http.Client {
customTransport := http.DefaultTransport.(*http.Transport).Clone()
customTransport.TLSClientConfig = &tls.Config{InsecureSkipVerify: allowInsecure}
httpClient := http.Client{
Transport: customTransport,
Timeout: time.Second * 90,
}
return &httpClient
}
// ResolveAddress returns whether or not an address is resolvable
func ResolveAddress(address string) error {
httpClient := &http.Client{Timeout: 10 * time.Second}
_, err := httpClient.Get(address)
if err != nil {
return err
}
return nil
}