Рейтинг@Mail.ru
Tarantool » 1.7 » Справочники » Built-in modules reference » Module uri

Module uri

Module uri

Overview

A «URI» is a «Uniform Resource Identifier». The IETF standard says a URI string looks like this:

[scheme:]scheme-specific-part[#fragment]

A common type, a hierarchical URI, looks like this:

[scheme:][//authority][path][?query][#fragment]

For example the string 'https://tarantool.org/x.html#y' has three components:

  • https is the scheme,
  • tarantool.org/x.html is the path,
  • y is the fragment.

Tarantool’s URI module provides routines which convert URI strings into their components, or turn components into URI strings.

Index

Below is a list of all uri functions.

Name Use
uri.parse() Get a table of URI components
uri.format() Construct a URI from components
uri.parse(URI-string)
Параметры:
  • URI-string – a Uniform Resource Identifier
Return:

URI-components-table. Possible components are fragment, host, login, password, path, query, scheme, service.

Rtype:

Table

Example:

tarantool> uri = require('uri')
---
...

tarantool> uri.parse('http://x.html#y')
---
- host: x.html
  scheme: http
  fragment: y
...
uri.format(URI-components-table)
Параметры:
  • URI-components-table – a series of name:value pairs, one for each component
Return:

URI-string. Thus uri.format() is the reverse of uri.parse().

Rtype:

string

Example:

tarantool> uri.format({host = 'x.html', scheme = 'http', fragment = 'y'})
---
- http://x.html#y
...