diff options
| author | Shulhan <ms@kilabit.info> | 2024-03-08 02:52:16 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2024-03-09 01:10:24 +0700 |
| commit | 29343294a596fd74f6f9cb917c8aac74ccb78094 (patch) | |
| tree | e9286ed53041b973cb6d767325034f30e504e1f5 /lib/http/server_example_test.go | |
| parent | 4e35c509a41cecb207bf6f52e7c9a529fa9f71fb (diff) | |
| download | pakakeh.go-29343294a596fd74f6f9cb917c8aac74ccb78094.tar.xz | |
lib/http: refactoring NewServer and NewClient
The NewServer and NewClient now accept non-pointer options, so the
caller unable to modify the options once the server or client has
been created.
Diffstat (limited to 'lib/http/server_example_test.go')
| -rw-r--r-- | lib/http/server_example_test.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/http/server_example_test.go b/lib/http/server_example_test.go index 74a60f2a..460a78fd 100644 --- a/lib/http/server_example_test.go +++ b/lib/http/server_example_test.go @@ -21,8 +21,7 @@ func ExampleServer_customHTTPStatusCode() { exp = CustomResponse{ Status: http.StatusBadRequest, } - - opts = &ServerOptions{ + opts = ServerOptions{ Address: "127.0.0.1:8123", } @@ -67,10 +66,12 @@ func ExampleServer_customHTTPStatusCode() { // Wait for the server fully started. time.Sleep(1 * time.Second) - clientOpts := &ClientOptions{ - ServerURL: `http://127.0.0.1:8123`, - } - client := NewClient(clientOpts) + var ( + clientOpts = ClientOptions{ + ServerURL: `http://127.0.0.1:8123`, + } + client = NewClient(clientOpts) + ) httpRes, resBody, err := client.PostJSON(epCustom.Path, nil, nil) //nolint: bodyclose if err != nil { |
