aboutsummaryrefslogtreecommitdiff
path: root/internal/source/source.go
diff options
context:
space:
mode:
authorMichael Matloob <matloob@golang.org>2023-08-28 13:39:03 -0400
committerMichael Matloob <matloob@golang.org>2023-08-29 23:29:11 +0000
commitebe617b30c52774fccf9d36331cbff31e99aaf9e (patch)
tree9b413e7ec61ce6a08e169d8ab95eb3bca1b1effc /internal/source/source.go
parent6b2c42d38504a02ea8b77abc7c592b64aa39109d (diff)
downloadgo-x-pkgsite-ebe617b30c52774fccf9d36331cbff31e99aaf9e.tar.xz
internal/source: inject *http.Client into source.NewClient
This removes the dependency from package source onto ochttp. The users of source.NewClient that want an ochttp.Transport can set the transport on the *http.Client. For golang/go#61399 Change-Id: Ifb7126c482f664ee5a359f594d9324f0fd90f8b2 Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/523510 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> kokoro-CI: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'internal/source/source.go')
-rw-r--r--internal/source/source.go13
1 files changed, 3 insertions, 10 deletions
diff --git a/internal/source/source.go b/internal/source/source.go
index 813b5d55..3435d589 100644
--- a/internal/source/source.go
+++ b/internal/source/source.go
@@ -30,9 +30,7 @@ import (
"regexp"
"strconv"
"strings"
- "time"
- "go.opencensus.io/plugin/ochttp"
"go.opencensus.io/trace"
"golang.org/x/net/context/ctxhttp"
"golang.org/x/pkgsite/internal/derrors"
@@ -206,14 +204,9 @@ type Client struct {
httpClient *http.Client
}
-// New constructs a *Client using the provided timeout.
-func NewClient(timeout time.Duration) *Client {
- return &Client{
- httpClient: &http.Client{
- Transport: &ochttp.Transport{},
- Timeout: timeout,
- },
- }
+// New constructs a *Client using the provided *http.Client.
+func NewClient(httpClient *http.Client) *Client {
+ return &Client{httpClient: httpClient}
}
// NewClientForTesting returns a Client suitable for testing. It returns the