Skip to content

Commit 3ac6f5b

Browse files
committed
Document the default client
1 parent fcc1f05 commit 3ac6f5b

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

doc/reference/reference_lua/http.rst

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,47 @@ The HTTP client uses the `libcurl <https://curl.haxx.se/libcurl/>`_ library unde
1212
takes into account the `environment variables <https://curl.haxx.se/libcurl/c/libcurl-env.html>`_ libcurl understands.
1313

1414

15+
.. _http_client_instance:
16+
17+
HTTP client instance
18+
--------------------
19+
20+
.. _http_client_instance_default:
21+
22+
Default client
23+
~~~~~~~~~~~~~~
24+
25+
The ``http.client`` submodule provides the default HTTP client instance:
26+
27+
.. literalinclude:: /code_snippets/test/http_client/default_client_get_test.lua
28+
:language: lua
29+
:lines: 1
30+
31+
In this case, you need to make requests using the dot syntax, for example:
32+
33+
.. literalinclude:: /code_snippets/test/http_client/default_client_get_test.lua
34+
:language: lua
35+
:lines: 2
36+
37+
1538
.. _creating_client:
1639

1740
Creating a client
18-
-----------------
41+
~~~~~~~~~~~~~~~~~
1942

20-
To create an HTTP client, call the :ref:`http.client.new() <http-new>` function:
43+
If you need to configure specific HTTP client options, use the :ref:`http.client.new() <http-new>` function to create the client instance:
2144

2245
.. literalinclude:: /code_snippets/test/http_client/get_test.lua
2346
:language: lua
2447
:lines: 1
2548

26-
Optionally, this function can accept specific client configuration options.
49+
In this case, you need to make requests using the colon syntax, for example:
50+
51+
.. literalinclude:: /code_snippets/test/http_client/get_test.lua
52+
:language: lua
53+
:lines: 2
54+
55+
All the examples in this section use the HTTP client created using ``http.client.new()``.
2756

2857

2958
.. _making_requests:

0 commit comments

Comments
 (0)