diff options
| author | Shulhan <ms@kilabit.info> | 2022-01-02 03:05:14 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-01-09 22:44:43 +0700 |
| commit | 0e49559d0effb845c8392e00a3b860464ed88002 (patch) | |
| tree | 99464987abd82d86e234a494d21b2199d2615237 /lib/http/endpoint_response_example_test.go | |
| parent | 7f89b4b38ad7155a44ac7384d8c08e2dd177780c (diff) | |
| download | pakakeh.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/endpoint_response_example_test.go')
| -rw-r--r-- | lib/http/endpoint_response_example_test.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/http/endpoint_response_example_test.go b/lib/http/endpoint_response_example_test.go index 6f98dc61..5e953f1b 100644 --- a/lib/http/endpoint_response_example_test.go +++ b/lib/http/endpoint_response_example_test.go @@ -67,7 +67,10 @@ func ExampleEndpointResponse() { }() time.Sleep(500) - cl := NewClient("http://127.0.0.1:7016", nil, true) + clientOpts := &ClientOptions{ + ServerUrl: "http://127.0.0.1:7016", + } + cl := NewClient(clientOpts) params := url.Values{} // Test call endpoint without "id" parameter. |
