update doc/*/scripting/builtins/libnetwork.md

This commit is contained in:
MihailRis 2025-04-30 19:16:35 +03:00
parent 556a561f1c
commit 5a42ec8bdc
2 changed files with 10 additions and 6 deletions

View File

@ -7,7 +7,8 @@ A library for working with the network.
```lua ```lua
-- Performs a GET request to the specified URL. -- Performs a GET request to the specified URL.
-- After receiving the response, passes the text to the callback function. -- After receiving the response, passes the text to the callback function.
network.get(url: str, callback: function(str)) -- In case of an error, the HTTP response code will be passed to onfailure.
network.get(url: str, callback: function(str), [optional] onfailure: function(int))
-- Example: -- Example:
network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s) network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s)
@ -15,12 +16,13 @@ network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/lat
end) end)
-- A variant for binary files, with a byte array instead of a string in the response. -- A variant for binary files, with a byte array instead of a string in the response.
network.get_binary(url: str, callback: function(table|ByteArray)) network.get_binary(url: str, callback: function(table|ByteArray), [optional] onfailure: function(int))
-- Performs a POST request to the specified URL. -- Performs a POST request to the specified URL.
-- Currently, only `Content-Type: application/json` is supported -- Currently, only `Content-Type: application/json` is supported
-- After receiving the response, passes the text to the callback function. -- After receiving the response, passes the text to the callback function.
network.post(url: str, data: table, callback: function(str)) -- In case of an error, the HTTP response code will be passed to onfailure.
network.post(url: str, data: table, callback: function(str), [optional] onfailure: function(int))
``` ```
## TCP Connections ## TCP Connections

View File

@ -7,7 +7,8 @@
```lua ```lua
-- Выполняет GET запрос к указанному URL. -- Выполняет GET запрос к указанному URL.
-- После получения ответа, передаёт текст в функцию callback. -- После получения ответа, передаёт текст в функцию callback.
network.get(url: str, callback: function(str)) -- В случае ошибки в onfailure будет передан HTTP-код ответа.
network.get(url: str, callback: function(str), [опционально] onfailure: function(int))
-- Пример: -- Пример:
network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s) network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/latest", function (s)
@ -15,12 +16,13 @@ network.get("https://api.github.com/repos/MihailRis/VoxelEngine-Cpp/releases/lat
end) end)
-- Вариант для двоичных файлов, с массивом байт вместо строки в ответе. -- Вариант для двоичных файлов, с массивом байт вместо строки в ответе.
network.get_binary(url: str, callback: function(table|ByteArray)) network.get_binary(url: str, callback: function(table|ByteArray), [опционально] onfailure: function(int))
-- Выполняет POST запрос к указанному URL. -- Выполняет POST запрос к указанному URL.
-- На данный момент реализована поддержка только `Content-Type: application/json` -- На данный момент реализована поддержка только `Content-Type: application/json`
-- После получения ответа, передаёт текст в функцию callback. -- После получения ответа, передаёт текст в функцию callback.
network.post(url: str, data: table, callback: function(str)) -- В случае ошибки в onfailure будет передан HTTP-код ответа.
network.post(url: str, data: table, callback: function(str), [опционально] onfailure: function(int))
``` ```
## TCP-Соединения ## TCP-Соединения