Make NewHTTPTransport return a concrete type.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -26,7 +26,7 @@ const ( |
| 26 | 26 |
dummyHost = "plugin.moby.localhost" |
| 27 | 27 |
) |
| 28 | 28 |
|
| 29 |
-func newTransport(addr string, tlsConfig *tlsconfig.Options) (transport.Transport, error) {
|
|
| 29 |
+func newTransport(addr string, tlsConfig *tlsconfig.Options) (*transport.HTTPTransport, error) {
|
|
| 30 | 30 |
tr := &http.Transport{}
|
| 31 | 31 |
|
| 32 | 32 |
if tlsConfig != nil {
|
| ... | ... |
@@ -77,7 +77,7 @@ func NewClientWithTimeout(addr string, tlsConfig *tlsconfig.Options, timeout tim |
| 77 | 77 |
} |
| 78 | 78 |
|
| 79 | 79 |
// newClientWithTransport creates a new plugin client with a given transport. |
| 80 |
-func newClientWithTransport(tr transport.Transport, timeout time.Duration) *Client {
|
|
| 80 |
+func newClientWithTransport(tr *transport.HTTPTransport, timeout time.Duration) *Client {
|
|
| 81 | 81 |
return &Client{
|
| 82 | 82 |
http: &http.Client{
|
| 83 | 83 |
Transport: tr, |
| ... | ... |
@@ -6,18 +6,18 @@ import ( |
| 6 | 6 |
"strings" |
| 7 | 7 |
) |
| 8 | 8 |
|
| 9 |
-// httpTransport holds an http.RoundTripper |
|
| 9 |
+// HTTPTransport holds an [http.RoundTripper] |
|
| 10 | 10 |
// and information about the scheme and address the transport |
| 11 | 11 |
// sends request to. |
| 12 |
-type httpTransport struct {
|
|
| 12 |
+type HTTPTransport struct {
|
|
| 13 | 13 |
http.RoundTripper |
| 14 | 14 |
scheme string |
| 15 | 15 |
addr string |
| 16 | 16 |
} |
| 17 | 17 |
|
| 18 |
-// NewHTTPTransport creates a new httpTransport. |
|
| 19 |
-func NewHTTPTransport(r http.RoundTripper, scheme, addr string) Transport {
|
|
| 20 |
- return httpTransport{
|
|
| 18 |
+// NewHTTPTransport creates a new HTTPTransport. |
|
| 19 |
+func NewHTTPTransport(r http.RoundTripper, scheme, addr string) *HTTPTransport {
|
|
| 20 |
+ return &HTTPTransport{
|
|
| 21 | 21 |
RoundTripper: r, |
| 22 | 22 |
scheme: scheme, |
| 23 | 23 |
addr: addr, |
| ... | ... |
@@ -26,7 +26,7 @@ func NewHTTPTransport(r http.RoundTripper, scheme, addr string) Transport {
|
| 26 | 26 |
|
| 27 | 27 |
// NewRequest creates a new http.Request and sets the URL |
| 28 | 28 |
// scheme and address with the transport's fields. |
| 29 |
-func (t httpTransport) NewRequest(path string, data io.Reader) (*http.Request, error) {
|
|
| 29 |
+func (t HTTPTransport) NewRequest(path string, data io.Reader) (*http.Request, error) {
|
|
| 30 | 30 |
if !strings.HasPrefix(path, "/") {
|
| 31 | 31 |
path = "/" + path |
| 32 | 32 |
} |