NewBasicAuthHTTPClient returns a new http client, with automatic Basic authentication. Specifically this means that the client will automatically add the Basic auth header to every request. The username and password are provided as arguments.
( //nolint:ireturn ctx context.Context, user, pass string, opts ...HeaderAuthClientOption, )
| 10 | // Specifically this means that the client will automatically add the Basic auth header |
| 11 | // to every request. The username and password are provided as arguments. |
| 12 | func NewBasicAuthHTTPClient( //nolint:ireturn |
| 13 | ctx context.Context, |
| 14 | user, pass string, |
| 15 | opts ...HeaderAuthClientOption, |
| 16 | ) (AuthenticatedHTTPClient, error) { |
| 17 | return NewHeaderAuthHTTPClient(ctx, append(opts, WithHeaders(Header{ |
| 18 | Key: "Authorization", |
| 19 | Value: "Basic " + basicAuth(user, pass), |
| 20 | }))...) |
| 21 | } |
| 22 | |
| 23 | // shamelessly stolen from https://pkg.go.dev/net/http#Request.SetBasicAuth |
| 24 | func basicAuth(username, password string) string { |
no test coverage detected