Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaime Martinez <jmartinez@gitlab.com>2021-02-09 02:08:18 +0300
committerJaime Martinez <jmartinez@gitlab.com>2021-02-09 02:08:18 +0300
commit8e1133c020d138eed58e22d5246b701bce9ed1a2 (patch)
tree323fa0631ed0983ea232dad5a56e288b580f9e2b /internal/httptransport
parentac442aa7dc7f603041d6643554576a561062d89a (diff)
Expose Transport interface wrapper
Diffstat (limited to 'internal/httptransport')
-rw-r--r--internal/httptransport/metered_round_tripper.go8
-rw-r--r--internal/httptransport/transport.go6
2 files changed, 13 insertions, 1 deletions
diff --git a/internal/httptransport/metered_round_tripper.go b/internal/httptransport/metered_round_tripper.go
index fc652086..ff79faca 100644
--- a/internal/httptransport/metered_round_tripper.go
+++ b/internal/httptransport/metered_round_tripper.go
@@ -39,7 +39,7 @@ func NewMeteredRoundTripper(transport *http.Transport, name string, tracerVec, d
}
}
-// RoundTripper wraps the original http.Transport into a meteredRoundTripper which
+// RoundTrip wraps the original http.Transport into a meteredRoundTripper which
// reports metrics on request duration, tracing and request count
func (mrt *meteredRoundTripper) RoundTrip(r *http.Request) (*http.Response, error) {
start := time.Now()
@@ -82,3 +82,9 @@ func (mrt *meteredRoundTripper) logResponse(req *http.Request, resp *http.Respon
l.Traceln("response")
}
}
+
+// RegisterProtocol allows to call RegisterProtocol on the meteredRoundTripper's transport
+// outside of this package
+func (mrt *meteredRoundTripper) RegisterProtocol(scheme string, rt http.RoundTripper) {
+ mrt.next.(*http.Transport).RegisterProtocol(scheme, rt)
+}
diff --git a/internal/httptransport/transport.go b/internal/httptransport/transport.go
index fcadc5fe..0b437a67 100644
--- a/internal/httptransport/transport.go
+++ b/internal/httptransport/transport.go
@@ -28,6 +28,12 @@ var (
DefaultTransport = NewTransport()
)
+// Transport wraps a RoundTripper so it can be extended and modified outside of this package
+type Transport interface {
+ http.RoundTripper
+ RegisterProtocol(scheme string, rt http.RoundTripper)
+}
+
// NewTransport initializes an http.Transport with a custom dialer that includes TLS Root CAs.
// It sets default connection values such as timeouts and max idle connections.
func NewTransport() *http.Transport {