Skip to content

Commit ce34bb4

Browse files
authored
Extend uri functions descriptions (#3165)
Resolves #3145
1 parent ec2d7db commit ce34bb4

File tree

1 file changed

+61
-14
lines changed

1 file changed

+61
-14
lines changed

doc/reference/reference_lua/uri.rst

Lines changed: 61 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
Overview
77
===============================================================================
88

9-
A "URI" is a "Uniform Resource Identifier".
9+
*URI* stands for *Uniform Resource Identifier* - a sequence of characters that
10+
identifies a logical or physical resource.
1011
The `IETF standard <https://www.ietf.org/rfc/rfc2396.txt>`_
1112
says a URI string looks like this:
1213

@@ -23,11 +24,11 @@ A common type, a hierarchical URI, looks like this:
2324
For example the string ``'https://tarantool.org/x.html#y'``
2425
has three components:
2526

26-
* ``https`` is the scheme,
27-
* ``tarantool.org/x.html`` is the path,
27+
* ``https`` is the scheme.
28+
* ``tarantool.org/x.html`` is the path.
2829
* ``y`` is the fragment.
2930

30-
Tarantool's URI module provides routines which convert URI strings into their
31+
Tarantool's URI module provides functions that convert URI strings into their
3132
components, or turn components into URI strings.
3233

3334
===============================================================================
@@ -57,9 +58,25 @@ Below is a list of all ``uri`` functions.
5758

5859
.. function:: parse(URI-string)
5960

61+
Parse a URI string into components. Possible components are:
62+
63+
* ``fragment``
64+
* ``host``
65+
* ``ipv4``
66+
* ``ipv6``
67+
* ``login``
68+
* ``password``
69+
* ``path``
70+
* ``query``
71+
* ``scheme``
72+
* ``service``
73+
* ``unix``
74+
75+
``uri.parse()`` is the reverse of :ref:`uri.format() <uri-format>`.
76+
6077
:param URI-string: a Uniform Resource Identifier
61-
:return: URI-components-table. Possible components are fragment, host,
62-
login, password, path, query, scheme, service.
78+
:return: URI components table.
79+
6380
:rtype: Table
6481

6582
**Example:**
@@ -70,31 +87,61 @@ Below is a list of all ``uri`` functions.
7087
---
7188
...
7289
73-
tarantool> uri.parse('http://x.html#y')
90+
tarantool> uri.parse('scheme://login:password@host:service'..
91+
'/path1/path2/path3?q1=v1&q2=v2&q3=v3:1|v3:2#fragment')
7492
---
75-
- host: x.html
76-
scheme: http
77-
fragment: y
93+
- login: login
94+
params:
95+
q1:
96+
- v1
97+
q2:
98+
- v2
99+
q3:
100+
- v3:1|v3:2
101+
service: service
102+
fragment: fragment
103+
password: password
104+
scheme: scheme
105+
query: q1=v1&q2=v2&q3=v3:1|v3:2
106+
host: host
107+
path: /path1/path2/path3
78108
...
79109
80110
.. _uri-format:
81111

82112
.. function:: format(URI-components-table[, include-password])
83113

84-
:param URI-components-table: a series of name:value pairs, one for each
114+
Form a URI string from its components. Possible components are:
115+
116+
* ``fragment``
117+
* ``host``
118+
* ``ipv4``
119+
* ``ipv6``
120+
* ``login``
121+
* ``password``
122+
* ``path``
123+
* ``query``
124+
* ``scheme``
125+
* ``service``
126+
* ``unix``
127+
128+
``uri.format()`` is the reverse of :ref:`uri.parse() <uri-parse>`.
129+
130+
:param URI-components-table: a series of ``name=value`` pairs, one for each
85131
component
86132
:param include-password: boolean. If this is supplied and is ``true``, then
87133
the password component is rendered in clear text,
88134
otherwise it is omitted.
89-
:return: URI-string. Thus uri.format() is the reverse of uri.parse().
135+
:return: URI string
90136
:rtype: string
91137

92138
**Example:**
93139

94140
.. code-block:: tarantoolsession
95141
96-
tarantool> uri.format({host = 'x.html', scheme = 'http', fragment = 'y'})
142+
tarantool> uri.format({scheme='scheme', login='login', password='password', host='host',
143+
service='service', path='/path1/path2/path3', query='q1=v1&q2=v2&q3=v3'})
97144
---
98-
- http://x.html#y
145+
- scheme://login@host:service/path1/path2/path3
99146
...
100147

0 commit comments

Comments
 (0)