add Net.Http to lua

This commit is contained in:
2025-07-31 20:37:31 +03:00
parent 75ee6e10aa
commit f411637520
3 changed files with 176 additions and 3 deletions

View File

@@ -21,4 +21,39 @@ Out = {
---@field EventWarn fun(msg: string)
---@type Log
Log = {}
Log = {}
---@class HttpResponse
---@field status integer HTTP status code
---@field status_text string HTTP status text
---@field body string Response body
---@field content_length integer Content length
---@field headers table<string, string|string[]> Response headers
---@class Http
---@field Get fun(log: boolean, url: string): HttpResponse, string? Makes HTTP GET request
---@field Post fun(log: boolean, url: string, content_type: string, payload: string): HttpResponse, string? Makes HTTP POST request
---@class Net
---@field Http Http HTTP client methods
---@type Net
Net = {
Http = {
---Makes HTTP GET request
---@param log boolean Whether to log the request
---@param url string URL to request
---@return HttpResponse response
---@return string? error
Get = function(log, url) end,
---Makes HTTP POST request
---@param log boolean Whether to log the request
---@param url string URL to request
---@param content_type string Content-Type header
---@param payload string Request body
---@return HttpResponse response
---@return string? error
Post = function(log, url, content_type, payload) end
}
}