Documentation ¶
Index ¶
Constants ¶
View Source
const (
CredFieldName = "client.http.auth.cred"
)
Variables ¶
View Source
var ( BasicAuthComponent = &app.Component{ Constructor: constructor, BindFlags: bindFlags, Run: func(c container.Container) error { config, err := container.Get[*Config](c) if err != nil { return err } configurator, err := container.Get[configurator.Configurator](c) if err != nil { return err } if config.Cred == "" { config.Cred = configurator.GetString(CredFieldName) } logger, err := container.Get[logger.Logger](c) if err != nil { return err } 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, err := container.Get[client.Doer](c) if err != nil { return err } 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.