aboutsummaryrefslogtreecommitdiff
path: root/lib/http/example_server_test.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-01-02 03:05:14 +0700
committerShulhan <ms@kilabit.info>2022-01-09 22:44:43 +0700
commit0e49559d0effb845c8392e00a3b860464ed88002 (patch)
tree99464987abd82d86e234a494d21b2199d2615237 /lib/http/example_server_test.go
parent7f89b4b38ad7155a44ac7384d8c08e2dd177780c (diff)
downloadpakakeh.go-0e49559d0effb845c8392e00a3b860464ed88002.tar.xz
lib/http: refactoring NewClient to accept single struct
Previously, the NewClient function accept three parameters: serverURL, http.Header, and insecure. If we want to add another parameter, for example timeout it will cause changes on the function signature. To prevent this changes in the future, we change it now. The NewClient now accept single struct. While at it, we add option to set Timeout. The Timeout affect the http Transport Timeout and TLSHandshakeTimeout. The field is optional, if not set it will set to 10 seconds.
Diffstat (limited to 'lib/http/example_server_test.go')
-rw-r--r--lib/http/example_server_test.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/http/example_server_test.go b/lib/http/example_server_test.go
index 2c886f27..aad952aa 100644
--- a/lib/http/example_server_test.go
+++ b/lib/http/example_server_test.go
@@ -60,7 +60,10 @@ func ExampleServer_customHTTPStatusCode() {
// Wait for the server fully started.
time.Sleep(1 * time.Second)
- client := NewClient("http://127.0.0.1:8123", nil, false)
+ clientOpts := &ClientOptions{
+ ServerUrl: "http://127.0.0.1:8123",
+ }
+ client := NewClient(clientOpts)
httpRes, resBody, err := client.PostJSON(epCustom.Path, nil, nil)
if err != nil {