Documentation ¶
Index ¶
Constants ¶
View Source
const (
CredFieldName = "client.http.auth.cred"
)
Variables ¶
View Source
var ( BasicAuthComponent = &app.Component{ Constructor: app.Constructor(func(container container.Container) error { return container.Provide(NewConfig) }), BindFlags: app.BindFlags(func(flagSet *pflag.FlagSet, container container.Container) error { return container.Invoke(func(config *Config) { flagSet.StringVar(&config.Cred, CredFieldName, "", "login:password pairs for basic authorization in http request") }) }), Run: app.Run(func(container container.Container) error { return container.Invoke(func( config *Config, configurator configurator.Configurator, logger logger.Logger, httpClient client.Doer, ) error { if config.Cred == "" { config.Cred = configurator.GetString(CredFieldName) } if config.Cred == "" { logger.Info("http.client.middleware: middleware for basic authorization in http client not added because cred is empty") return nil } cred := strings.Split(config.Cred, credSeparator) httpClient.Use(Basic( &Cred{ UserName: cred[0], Password: cred[1], }, logger, )) return nil }) }), } )
Functions ¶
func NewBasic ¶
func NewBasic(originalTransport http.RoundTripper, cred *Cred) http.RoundTripper
Types ¶
Click to show internal directories.
Click to hide internal directories.