(isHTTPS, secure bool, baseURL string)
| 24 | } |
| 25 | |
| 26 | func newHTTPWrapperServiceClient(isHTTPS, secure bool, baseURL string) *httpWrapperServiceClient { |
| 27 | netDialer := &net.Dialer{} |
| 28 | |
| 29 | // By default, block both things |
| 30 | netDial := func(_ context.Context, network, addr string) (net.Conn, error) { |
| 31 | return nil, fmt.Errorf("%w: cannot connect to %v:%v TLS must be used", errServiceClient, network, addr) |
| 32 | } |
| 33 | dialTLS := func(_ context.Context, network string, addr string) (net.Conn, error) { |
| 34 | return nil, fmt.Errorf("%w: cannot connect to %v:%v TLS is not supported", errServiceClient, network, addr) |
| 35 | } |
| 36 | |
| 37 | // Unblock one of the dial methods |
| 38 | if isHTTPS { |
| 39 | tlsDialer := tls.Dialer{ |
| 40 | NetDialer: netDialer, |
| 41 | Config: &tls.Config{ |
| 42 | InsecureSkipVerify: !secure, // nolint:gosec |
| 43 | }, |
| 44 | } |
| 45 | dialTLS = tlsDialer.DialContext |
| 46 | } else { |
| 47 | netDial = netDialer.DialContext |
| 48 | } |
| 49 | |
| 50 | transport := &http.Transport{ |
| 51 | DialContext: netDial, |
| 52 | DialTLSContext: dialTLS, |
| 53 | MaxIdleConns: 2, |
| 54 | MaxConnsPerHost: 2, |
| 55 | } |
| 56 | return newHTTPWrapperServiceClientWithTransport(transport, baseURL) |
| 57 | } |
| 58 | |
| 59 | func newHTTPWrapperServiceClientWithTransport(transport http.RoundTripper, baseURL string) *httpWrapperServiceClient { |
| 60 | return &httpWrapperServiceClient{ |
no test coverage detected