MCPcopy Create free account
hub / github.com/amp-labs/connectors / NewBasicAuthHTTPClient

Function NewBasicAuthHTTPClient

common/basic.go:12–21  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

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.
12func 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
24func basicAuth(username, password string) string {

Callers 8

NewBasicAuthClientFunction · 0.92
GetAshbyConnectorFunction · 0.92
GetChargebeeConnectorFunction · 0.92
NewConnectorFunction · 0.92
NewConnectorFunction · 0.92
GetBlueshiftConnectorFunction · 0.92
WithBasicClientMethod · 0.92

Calls 3

NewHeaderAuthHTTPClientFunction · 0.85
WithHeadersFunction · 0.85
basicAuthFunction · 0.85

Tested by

no test coverage detected