aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2024-12-12 21:12:26 +0700
committerShulhan <ms@kilabit.info>2024-12-28 14:40:53 +0700
commitd8a4dae6ad9672285dc007e7c52c63026278d00a (patch)
tree6f98e56a5ea667c40acf5732c4549a7b8c022880
parent51fc85b0e41cd6141866b4ad075d844482fb880f (diff)
downloadpakakeh.go-d8a4dae6ad9672285dc007e7c52c63026278d00a.tar.xz
lib/http: add method to return default HTTP Transport in Client
The returned [http.Transport] is created after the Client instantiated. Their value can be customized by user when needed, which should affect the Transport inside the Client.
-rw-r--r--lib/http/client.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/http/client.go b/lib/http/client.go
index d5045fee..2dad2159 100644
--- a/lib/http/client.go
+++ b/lib/http/client.go
@@ -1,6 +1,6 @@
-// Copyright 2020, Shulhan <ms@kilabit.info>. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
+// SPDX-FileCopyrightText: 2020 M. Shulhan <ms@kilabit.info>
+//
+// SPDX-License-Identifier: BSD-3-Clause
package http
@@ -450,6 +450,13 @@ func (client *Client) PutJSON(req ClientRequest) (res *ClientResponse, err error
return client.doRequest(req)
}
+// Transport return the [http.Transport] that Client use in the
+// RoundTripper.
+func (client *Client) Transport() (transport *http.Transport) {
+ transport, _ = client.Client.Transport.(*http.Transport)
+ return transport
+}
+
func (client *Client) doRequest(req ClientRequest) (res *ClientResponse, err error) {
req.Path = path.Join(`/`, req.Path)