From a06f28f122a301ed9374fc3ba64dda0f71debf52 Mon Sep 17 00:00:00 2001 From: William Perron Date: Mon, 10 Jul 2023 08:21:11 -0400 Subject: [PATCH] Add basic auth round tripper to http --- http/round_tripper.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/http/round_tripper.go b/http/round_tripper.go index 4630f26..6e8f739 100644 --- a/http/round_tripper.go +++ b/http/round_tripper.go @@ -44,3 +44,14 @@ func (f *FollowRedirect) RoundTrip(req *stdhttp.Request) (*stdhttp.Response, err } return res, nil } + +type BasicAuthRoundTripper struct { + u, p string + + next stdhttp.RoundTripper +} + +func (bart *BasicAuthRoundTripper) RoundTrip(req *stdhttp.Request) (*stdhttp.Response, error) { + req.SetBasicAuth(bart.u, bart.p) + return bart.next.RoundTrip(req) +}