Allow client.Config to wrap the underyling Transport

This commit is contained in:
Clayton Coleman 2015-04-11 12:45:30 -04:00
parent 66e746bade
commit 0146e318f5

View File

@ -75,8 +75,14 @@ type Config struct {
UserAgent string
// Transport may be used for custom HTTP behavior. This attribute may not
// be specified with the TLS client certificate options.
// be specified with the TLS client certificate options. Use WrapTransport
// for most client level operations.
Transport http.RoundTripper
// WrapTransport will be invoked for custom HTTP behavior after the underlying
// transport is initialized (either the transport created from TLSClientConfig,
// Transport, or http.DefaultTransport). The config may layer other RoundTrippers
// on top of the returned RoundTripper.
WrapTransport func(rt http.RoundTripper) http.RoundTripper
// QPS indicates the maximum QPS to the master from this client. If zero, QPS is unlimited.
QPS float32
@ -255,6 +261,9 @@ func TransportFor(config *Config) (http.RoundTripper, error) {
transport = http.DefaultTransport
}
}
if config.WrapTransport != nil {
transport = config.WrapTransport(transport)
}
transport, err = HTTPWrappersForConfig(config, transport)
if err != nil {