gitlab.com/gitlab-org/labkit@v1.21.0/correlation/outbound_http_options.go (about)

     1  package correlation
     2  
     3  // The configuration for InjectCorrelationID.
     4  type instrumentedRoundTripperConfig struct {
     5  	clientName string
     6  }
     7  
     8  // InstrumentedRoundTripperOption will configure a correlation handler
     9  // currently there are no options, but this gives us the option
    10  // to extend the interface in a backwards compatible way.
    11  type InstrumentedRoundTripperOption func(*instrumentedRoundTripperConfig)
    12  
    13  func applyInstrumentedRoundTripperOptions(opts []InstrumentedRoundTripperOption) instrumentedRoundTripperConfig {
    14  	config := instrumentedRoundTripperConfig{}
    15  	for _, v := range opts {
    16  		v(&config)
    17  	}
    18  
    19  	return config
    20  }
    21  
    22  // WithClientName will configure the X-GitLab-Client-Name header on the
    23  // http client.
    24  func WithClientName(clientName string) InstrumentedRoundTripperOption {
    25  	return func(config *instrumentedRoundTripperConfig) {
    26  		config.clientName = clientName
    27  	}
    28  }