func WithMaxIdleConnsPerHost(conns int) ClientOrHTTPClientParam {
	return clientOrHTTPClientParamFunc(func(b *httpClientBuilder) error {
		b.TransportParams = refreshingclient.ConfigureTransport(b.TransportParams, func(p refreshingclient.TransportParams) refreshingclient.TransportParams {
			p.MaxIdleConnsPerHost = conns
			return p
		})
		return nil
	})
}
WithMaxIdleConnsPerHost sets the number of reusable TCP connections the client
will maintain per destination. If unset, the client defaults to 32.
package httpclient
import (
	"context"
	"crypto/tls"
	"encoding/base64"
	"net/http"
	"net/url"
	"time"
	"github.com/palantir/conjure-go-runtime/v2/conjure-go-client/httpclient/internal"
	"github.com/palantir/conjure-go-runtime/v2/conjure-go-client/httpclient/internal/refreshingclient"
	"github.com/palantir/pkg/bytesbuffers"
	"github.com/palantir/pkg/metrics"
	"github.com/palantir/pkg/refreshable"
	werror "github.com/palantir/witchcraft-go-error"
)
type ClientParam interface {
	apply(builder *clientBuilder) error
}
type HTTPClientParam interface {
	applyHTTPClient(builder *httpClientBuilder) error
}
type ClientOrHTTPClientParam interface {
	ClientParam
	HTTPClientParam
}
type clientParamFunc func(builder *clientBuilder) error
func (f clientParamFunc) apply(b *clientBuilder) error {
	return f(b)
}
type httpClientParamFunc func(builder *httpClientBuilder) error
func (f httpClientParamFunc) applyHTTPClient(b *httpClientBuilder) error {
	return f(b)
}
type clientOrHTTPClientParamFunc func(builder *httpClientBuilder) error
func (f clientOrHTTPClientParamFunc) apply(b *clientBuilder) error {
	return f(b.HTTP)
}
func (f clientOrHTTPClientParamFunc) applyHTTPClient(b *httpClientBuilder) error {
	return f(b)
}
func WithConfig(c ClientConfig) ClientParam {
	return clientParamFunc(func(b *clientBuilder) error {
		params, err := configToParams(c)
		if err != nil {
			return err
		}
		for _, p := range params {
			if err := p.apply(b); err != nil {
				return err
			}
		}
		return nil
	})
}
func WithConfigForHTTPClient(c ClientConfig) HTTPClientParam {
	return httpClientParamFunc(func(b *httpClientBuilder) error {
		params, err := configToParams(c)
		if err != nil {
			return err
		}
		for _, p := range params {
			httpClientParam, ok := p.(HTTPClientParam)
			if !ok {
				return werror.Error("param from config was not a http client builder param")
			}
			if err := httpClientParam.applyHTTPClient(b); err != nil {
				return err
			}
		}
		return nil
	})
}
func WithServiceName(serviceName string) ClientOrHTTPClientParam {
	return clientOrHTTPClientParamFunc(func(b *httpClientBuilder) error {
		tag, err := metrics.NewTag(MetricTagServiceName, serviceName)
		if err != nil {
			return err
		}
		b.ServiceNameTag = tag
		return nil
	})
}
func WithMiddleware(h Middleware) ClientOrHTTPClientParam {
	return clientOrHTTPClientParamFunc(func(b *httpClientBuilder) error {
		b.Middlewares = append(b.Middlewares, h)
		return nil
	})
}
func WithAddHeader(key, value string) ClientOrHTTPClientParam {
	return WithMiddleware(MiddlewareFunc(func(req *http.Request, next http.RoundTripper) (*http.Response, error) {
		req.Header.Add(key, value)
		return next.RoundTrip(req)
	}))
}
func WithSetHeader(key, value string) ClientOrHTTPClientParam {
	return WithMiddleware(MiddlewareFunc(func(req *http.Request, next http.RoundTripper) (*http.Response, error) {
		req.Header.Set(key, value)
		return next.RoundTrip(req)
	}))
}
func WithAuthToken(bearerToken string) ClientOrHTTPClientParam {
	return WithAuthTokenProvider(func(context.Context) (string, error) {
		return bearerToken, nil
	})
}
func WithAuthTokenProvider(provideToken TokenProvider) ClientOrHTTPClientParam {
	return WithMiddleware(&authTokenMiddleware{provideToken: provideToken})
}
func WithUserAgent(userAgent string) ClientOrHTTPClientParam {
	return WithSetHeader("User-Agent", userAgent)
}
func WithMetrics(tagProviders ...TagsProvider) ClientOrHTTPClientParam {
	return clientOrHTTPClientParamFunc(func(b *httpClientBuilder) error {
		b.DisableMetrics = refreshable.NewBool(refreshable.NewDefaultRefreshable(false))
		b.MetricsTagProviders = append(b.MetricsTagProviders, tagProviders...)
		return nil
	})
}
func WithBytesBufferPool(pool bytesbuffers.Pool) ClientParam {
	return clientParamFunc(func(b *clientBuilder) error {
		b.BytesBufferPool = pool
		return nil
	})
}
func WithDisablePanicRecovery() ClientOrHTTPClientParam {
	return clientOrHTTPClientParamFunc(func(b *httpClientBuilder) error {
		b.DisableRecovery = true
		return nil
	})
}
func WithDisableTracing() ClientOrHTTPClientParam {
	return clientOrHTTPClientParamFunc(func(b *httpClientBuilder) error {
		b.CreateRequestSpan = false
		return nil
	})
}
func WithDisableTraceHeaderPropagation() ClientOrHTTPClientParam {
	return clientOrHTTPClientParamFunc(func(b *httpClientBuilder) error {
		b.InjectTraceHeaders = false
		return nil
	})
}
func WithHTTPTimeout(timeout time.Duration) ClientOrHTTPClientParam {
	return clientOrHTTPClientParamFunc(func(b *httpClientBuilder) error {
		b.Timeout = refreshable.NewDuration(refreshable.NewDefaultRefreshable(timeout))
		return nil
	})
}
func WithDisableHTTP2() ClientOrHTTPClientParam {
	return clientOrHTTPClientParamFunc(func(b *httpClientBuilder) error {
		b.TransportParams = refreshingclient.ConfigureTransport(b.TransportParams, func(p refreshingclient.TransportParams) refreshingclient.TransportParams {
			p.DisableHTTP2 = true
			return p
		})
		return nil
	})
}
func WithHTTP2ReadIdleTimeout(timeout time.Duration) ClientOrHTTPClientParam {
	return clientOrHTTPClientParamFunc(func(b *httpClientBuilder) error {
		b.TransportParams = refreshingclient.ConfigureTransport(b.TransportParams, func(p refreshingclient.TransportParams) refreshingclient.TransportParams {
			p.HTTP2ReadIdleTimeout = timeout
			return p
		})
		return nil
	})
}
func WithHTTP2PingTimeout(timeout time.Duration) ClientOrHTTPClientParam {
	return clientOrHTTPClientParamFunc(func(b *httpClientBuilder) error {
		b.TransportParams = refreshingclient.ConfigureTransport(b.TransportParams, func(p refreshingclient.TransportParams) refreshingclient.TransportParams {
			p.HTTP2PingTimeout = timeout
			return p
		})
		return nil
	})
}
func WithMaxIdleConns(conns int) ClientOrHTTPClientParam {
	return clientOrHTTPClientParamFunc(func(b *httpClientBuilder) error {
		b.TransportParams = refreshingclient.ConfigureTransport(b.TransportParams, func(p refreshingclient.TransportParams) refreshingclient.TransportParams {
			p.MaxIdleConns = conns
			return p
		})
		return nil
	})
}